public class GridFSBinaryManager extends AbstractBinaryManager implements BlobProvider
BinaryManager and BlobProvider interface using MongoDB GridFS.
This implementation does not use local caching.
This implementation may not always be ideal regarding streaming because of the usage of Binary interface that
exposes a File.
| Modifier and Type | Class and Description |
|---|---|
protected class |
GridFSBinaryManager.GridFSBinary
A binary backed by GridFS.
|
class |
GridFSBinaryManager.GridFSBinaryGarbageCollector |
| Modifier and Type | Field and Description |
|---|---|
static String |
BLOB_PROVIDER_CONNECTION_PREFIX
Prefix used to retrieve a MongoDB connection from
MongoDBConnectionService. |
static String |
BUCKET_PROPERTY |
static String |
DBNAME_PROPERTY
Deprecated.
since 9.3 use
MongoDBConnectionService to provide access instead |
protected com.mongodb.client.MongoCollection<org.bson.Document> |
filesColl |
protected com.mongodb.gridfs.GridFS |
gridFS
Deprecated.
|
protected com.mongodb.client.gridfs.GridFSBucket |
gridFSBucket |
protected Map<String,String> |
properties |
static String |
SERVER_PROPERTY
Deprecated.
since 9.3 use
MongoDBConnectionService to provide access instead |
blobProviderId, DEFAULT_DEPTH, DEFAULT_DIGEST, descriptor, DIGESTS_BY_LENGTH, garbageCollector, MAX_BUF_SIZE, MD5_DIGEST, MD5_DIGEST_LENGTH, MIN_BUF_SIZE, SHA1_DIGEST, SHA1_DIGEST_LENGTH, SHA256_DIGEST, SHA256_DIGEST_LENGTHPROP_KEY, PROP_PATH| Constructor and Description |
|---|
GridFSBinaryManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this blob provider and releases resources that may be held by it.
|
Binary |
getBinary(Blob blob)
Saves the given blob into a
Binary. |
protected Binary |
getBinary(InputStream in)
Creates a binary value from the given input stream.
|
Binary |
getBinary(String digest)
Returns a
Binary corresponding to the given digest. |
BinaryManager |
getBinaryManager()
Gets the associated binary manager, if any.
|
protected com.mongodb.client.gridfs.GridFSBucket |
getGridFSBucket() |
Map<String,String> |
getProperties()
Returns the properties of the blob provider.
|
void |
initialize(String blobProviderId,
Map<String,String> properties)
Initializes the binary manager.
|
Blob |
readBlob(BlobInfo blobInfo)
Reads a
Blob from storage. |
boolean |
supportsUserUpdate()
Checks if user update is supported.
|
String |
writeBlob(Blob blob)
Writes a
Blob to storage and returns information about it. |
getDefaultDigestAlgorithm, getDescriptor, getDigestAlgorithm, getGarbageCollector, removeBinaries, storeAndDigest, toHexStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanConvert, getAppLinks, getAvailableConversions, getStream, getThumbnail, getURI, hasCreateFromKeyPermission, isTransient, isVersion, performsExternalAccessControlpublic static final String BLOB_PROVIDER_CONNECTION_PREFIX
MongoDBConnectionService.
The connection id will be blobProvider/[BLOB_PROVIDER_ID].@Deprecated public static final String SERVER_PROPERTY
MongoDBConnectionService to provide access instead@Deprecated public static final String DBNAME_PROPERTY
MongoDBConnectionService to provide access insteadpublic static final String BUCKET_PROPERTY
protected Map<String,String> properties
@Deprecated protected com.mongodb.gridfs.GridFS gridFS
protected com.mongodb.client.gridfs.GridFSBucket gridFSBucket
protected com.mongodb.client.MongoCollection<org.bson.Document> filesColl
public GridFSBinaryManager()
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
BinaryManagerinitialize in interface BinaryManagerinitialize in interface BlobProviderinitialize in class AbstractBinaryManagerblobProviderId - the blob provider id for this binary managerproperties - initialization propertiesIOExceptionpublic void close()
BlobProviderclose in interface BinaryManagerclose in interface BlobProviderpublic BinaryManager getBinaryManager()
BlobProvidergetBinaryManager in interface BlobProvidernullprotected com.mongodb.client.gridfs.GridFSBucket getGridFSBucket()
public Binary getBinary(Blob blob) throws IOException
BinaryManagerBinary.
Returns a Binary representing the stream. The Binary includes a digest that is a sufficient
representation to persist it.
If the blob is a temporary FileBlob, then the temporary file may be reused as the final storage location
after being moved.
getBinary in interface BinaryManagergetBinary in class AbstractBinaryManagerblob - the blobIOExceptionprotected Binary getBinary(InputStream in) throws IOException
AbstractBinaryManagergetBinary in class AbstractBinaryManagerIOExceptionpublic Binary getBinary(String digest)
BinaryManagerBinary corresponding to the given digest.
A null is returned if the digest could not be found.
getBinary in interface BinaryManagergetBinary in class AbstractBinaryManagerdigest - the digest, or nullpublic Blob readBlob(BlobInfo blobInfo) throws IOException
BlobProviderBlob from storage.readBlob in interface BlobProviderblobInfo - the blob informationIOExceptionpublic String writeBlob(Blob blob) throws IOException
BlobProviderBlob to storage and returns information about it.
Called to store a user-created blob.
writeBlob in interface BlobProviderblob - the blobIOExceptionpublic boolean supportsUserUpdate()
BlobProviderA user update refers to the fact that a blob from this provider may be overwritten with another blob, wherever the original blob may occur (usually in a document property).
supportsUserUpdate in interface BlobProvidertrue if user update is supportedpublic Map<String,String> getProperties()
BlobProvidergetProperties in interface BlobProviderCopyright © 2019 Nuxeo. All rights reserved.