public class SimplePreviewStorage extends java.lang.Object implements PreviewStorage, java.io.Serializable, LRUStorageManagedDirectory.DeleteHandler
| Modifier and Type | Class and Description |
|---|---|
protected class |
SimplePreviewStorage.NotifyingFileOutputStream |
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_CACHE_AGE
Max cache age in days - Redefine this constant to change the default policy.
|
static long |
MAX_CACHE_SIZE
Max cache size in bytes - Redefine this constant to change the default policy.
|
| Constructor and Description |
|---|
SimplePreviewStorage(BoxSession session) |
SimplePreviewStorage(BoxSession session,
long maxCacheSize,
int expirationDays)
Default implementation of Serializable PreviewStorage
|
| Modifier and Type | Method and Description |
|---|---|
void |
cacheMetadata(BoxFile metadata,
java.lang.String tag) |
java.io.OutputStream |
createPreviewOutputStream(BoxFile boxFile)
This stream must be flushed upon successful completion.
|
java.io.OutputStream |
createThumbnailOutputStream(BoxFile boxFile)
This stream must be flushed upon successful completion.
|
java.io.InputStream |
getCachedPreview(BoxFile boxFile) |
java.io.InputStream |
getCachedThumbnail(BoxFile boxFile) |
<T extends BoxFile> |
getMetadata(BoxFile fileInfo,
java.lang.String tag) |
java.io.File |
getPreviewFile(BoxFile boxFile) |
void |
onFileDeleted(java.io.File file,
boolean deleteSuccessful) |
boolean |
shouldDelete(java.io.File file) |
public static long MAX_CACHE_SIZE
public static int MAX_CACHE_AGE
public SimplePreviewStorage(BoxSession session,
long maxCacheSize,
int expirationDays)
session - - BoxSession from the content sdk after the user is authenticatedmaxCacheSize - - Maximum size of the cache in bytes.expirationDays - - Days beyond which files in cache can be clearedpublic SimplePreviewStorage(BoxSession session)
public boolean shouldDelete(java.io.File file)
shouldDelete in interface LRUStorageManagedDirectory.DeleteHandlerfile - the file this class is planning to delete.public void onFileDeleted(java.io.File file,
boolean deleteSuccessful)
onFileDeleted in interface LRUStorageManagedDirectory.DeleteHandlerfile - the file this class attempted to delete.deleteSuccessful - true if the file was successfully deleted, false if the delete failed.public java.io.InputStream getCachedPreview(BoxFile boxFile)
getCachedPreview in interface PreviewStoragepublic java.io.InputStream getCachedThumbnail(BoxFile boxFile)
getCachedThumbnail in interface PreviewStoragepublic java.io.File getPreviewFile(BoxFile boxFile)
getPreviewFile in interface PreviewStoragepublic java.io.OutputStream createThumbnailOutputStream(BoxFile boxFile)
createThumbnailOutputStream in interface PreviewStorageboxFile - the box file to get stream for.public java.io.OutputStream createPreviewOutputStream(BoxFile boxFile)
createPreviewOutputStream in interface PreviewStorageboxFile - the box file to get stream for.public void cacheMetadata(BoxFile metadata,
java.lang.String tag)
cacheMetadata in interface PreviewStoragepublic <T extends BoxFile> T getMetadata(BoxFile fileInfo,
java.lang.String tag)
getMetadata in interface PreviewStorage