final class GridFSBucketImpl extends java.lang.Object implements GridFSBucket
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
bucketName |
private MongoCollection<Document> |
chunksCollection |
private int |
chunkSizeBytes |
private static int |
DEFAULT_BUFFER_SIZE |
private static int |
DEFAULT_CHUNKSIZE_BYTES |
private MongoCollection<GridFSFile> |
filesCollection |
private static Logger |
LOGGER |
| Constructor and Description |
|---|
GridFSBucketImpl(MongoDatabase database) |
GridFSBucketImpl(MongoDatabase database,
java.lang.String bucketName) |
GridFSBucketImpl(java.lang.String bucketName,
int chunkSizeBytes,
MongoCollection<GridFSFile> filesCollection,
MongoCollection<Document> chunksCollection) |
| Modifier and Type | Method and Description |
|---|---|
private FindIterable<GridFSFile> |
createFindIterable(ClientSession clientSession,
Bson filter) |
private GridFSDownloadStream |
createGridFSDownloadStream(ClientSession clientSession,
GridFSFindIterable gridFSFindIterable) |
private GridFSFindIterable |
createGridFSFindIterable(ClientSession clientSession,
Bson filter) |
private GridFSFindIterable |
createGridFSFindIterable(ClientSession clientSession,
java.lang.String filename,
GridFSDownloadOptions options) |
private GridFSUploadStream |
createGridFSUploadStream(ClientSession clientSession,
BsonValue id,
java.lang.String filename,
GridFSUploadOptions options) |
void |
delete(BsonValue id,
SingleResultCallback<java.lang.Void> callback)
Given a
id, delete this stored file's files collection document and associated chunks from a GridFS bucket. |
void |
delete(ClientSession clientSession,
BsonValue id,
SingleResultCallback<java.lang.Void> callback)
Given a
id, delete this stored file's files collection document and associated chunks from a GridFS bucket. |
void |
delete(ClientSession clientSession,
ObjectId id,
SingleResultCallback<java.lang.Void> callback)
Given a
id, delete this stored file's files collection document and associated chunks from a GridFS bucket. |
void |
delete(ObjectId id,
SingleResultCallback<java.lang.Void> callback)
Given a
id, delete this stored file's files collection document and associated chunks from a GridFS bucket. |
private void |
downloadToAsyncOutputStream(GridFSDownloadStream downloadStream,
AsyncOutputStream destination,
SingleResultCallback<java.lang.Long> callback) |
void |
downloadToStream(BsonValue id,
AsyncOutputStream destination,
SingleResultCallback<java.lang.Long> callback)
Downloads the contents of the stored file specified by
id and writes the contents to the destination
AsyncOutputStream. |
void |
downloadToStream(ClientSession clientSession,
BsonValue id,
AsyncOutputStream destination,
SingleResultCallback<java.lang.Long> callback)
Downloads the contents of the stored file specified by
id and writes the contents to the destination
AsyncOutputStream. |
void |
downloadToStream(ClientSession clientSession,
ObjectId id,
AsyncOutputStream destination,
SingleResultCallback<java.lang.Long> callback)
Downloads the contents of the stored file specified by
id and writes the contents to the destination
AsyncOutputStream. |
void |
downloadToStream(ClientSession clientSession,
java.lang.String filename,
AsyncOutputStream destination,
GridFSDownloadOptions options,
SingleResultCallback<java.lang.Long> callback)
Downloads the contents of the stored file specified by
filename and by the revision in options and writes the
contents to the destination Stream. |
void |
downloadToStream(ClientSession clientSession,
java.lang.String filename,
AsyncOutputStream destination,
SingleResultCallback<java.lang.Long> callback)
Downloads the contents of the latest version of the stored file specified by
filename and writes the contents to
the destination Stream. |
void |
downloadToStream(ObjectId id,
AsyncOutputStream destination,
SingleResultCallback<java.lang.Long> callback)
Downloads the contents of the stored file specified by
id and writes the contents to the destination
AsyncOutputStream. |
void |
downloadToStream(java.lang.String filename,
AsyncOutputStream destination,
GridFSDownloadOptions options,
SingleResultCallback<java.lang.Long> callback)
Downloads the contents of the stored file specified by
filename and by the revision in options and writes the
contents to the destination Stream. |
void |
downloadToStream(java.lang.String filename,
AsyncOutputStream destination,
SingleResultCallback<java.lang.Long> callback)
Downloads the contents of the latest version of the stored file specified by
filename and writes the contents to
the destination Stream. |
void |
drop(ClientSession clientSession,
SingleResultCallback<java.lang.Void> callback)
Drops the data associated with this bucket from the database.
|
void |
drop(SingleResultCallback<java.lang.Void> callback)
Drops the data associated with this bucket from the database.
|
private void |
executeDelete(ClientSession clientSession,
BsonValue id,
SingleResultCallback<java.lang.Void> callback) |
private void |
executeDrop(ClientSession clientSession,
SingleResultCallback<java.lang.Void> callback) |
private void |
executeRename(ClientSession clientSession,
BsonValue id,
java.lang.String newFilename,
SingleResultCallback<java.lang.Void> callback) |
private void |
executeUploadFromStream(ClientSession clientSession,
BsonValue id,
java.lang.String filename,
AsyncInputStream source,
GridFSUploadOptions options,
SingleResultCallback<java.lang.Void> callback) |
GridFSFindIterable |
find()
Finds all documents in the files collection.
|
GridFSFindIterable |
find(Bson filter)
Finds all documents in the collection that match the filter.
|
GridFSFindIterable |
find(ClientSession clientSession)
Finds all documents in the files collection.
|
GridFSFindIterable |
find(ClientSession clientSession,
Bson filter)
Finds all documents in the collection that match the filter.
|
java.lang.String |
getBucketName()
The bucket name.
|
private static MongoCollection<Document> |
getChunksCollection(MongoDatabase database,
java.lang.String bucketName) |
int |
getChunkSizeBytes()
Sets the chunk size in bytes.
|
private static MongoCollection<GridFSFile> |
getFilesCollection(MongoDatabase database,
java.lang.String bucketName) |
ReadConcern |
getReadConcern()
Get the read concern for the GridFSBucket.
|
ReadPreference |
getReadPreference()
Get the read preference for the GridFSBucket.
|
WriteConcern |
getWriteConcern()
Get the write concern for the GridFSBucket.
|
GridFSDownloadStream |
openDownloadStream(BsonValue id)
Opens a AsyncInputStream from which the application can read the contents of the stored file specified by
id. |
GridFSDownloadStream |
openDownloadStream(ClientSession clientSession,
BsonValue id)
Opens a AsyncInputStream from which the application can read the contents of the stored file specified by
id. |
GridFSDownloadStream |
openDownloadStream(ClientSession clientSession,
ObjectId id)
Opens a AsyncInputStream from which the application can read the contents of the stored file specified by
id. |
GridFSDownloadStream |
openDownloadStream(ClientSession clientSession,
java.lang.String filename)
Opens a Stream from which the application can read the contents of the latest version of the stored file specified by the
filename. |
GridFSDownloadStream |
openDownloadStream(ClientSession clientSession,
java.lang.String filename,
GridFSDownloadOptions options)
Opens a Stream from which the application can read the contents of the stored file specified by
filename and the revision
in options. |
GridFSDownloadStream |
openDownloadStream(ObjectId id)
Opens a AsyncInputStream from which the application can read the contents of the stored file specified by
id. |
GridFSDownloadStream |
openDownloadStream(java.lang.String filename)
Opens a Stream from which the application can read the contents of the latest version of the stored file specified by the
filename. |
GridFSDownloadStream |
openDownloadStream(java.lang.String filename,
GridFSDownloadOptions options)
Opens a Stream from which the application can read the contents of the stored file specified by
filename and the revision
in options. |
GridFSUploadStream |
openUploadStream(BsonValue id,
java.lang.String filename)
Opens a AsyncOutputStream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(BsonValue id,
java.lang.String filename,
GridFSUploadOptions options)
Opens a AsyncOutputStream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(ClientSession clientSession,
BsonValue id,
java.lang.String filename)
Opens a AsyncOutputStream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(ClientSession clientSession,
BsonValue id,
java.lang.String filename,
GridFSUploadOptions options)
Opens a AsyncOutputStream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(ClientSession clientSession,
java.lang.String filename)
Opens a AsyncOutputStream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(ClientSession clientSession,
java.lang.String filename,
GridFSUploadOptions options)
Opens a AsyncOutputStream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(java.lang.String filename)
Opens a AsyncOutputStream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(java.lang.String filename,
GridFSUploadOptions options)
Opens a AsyncOutputStream that the application can write the contents of the file to.
|
private void |
readAndWriteInputStream(AsyncInputStream source,
GridFSUploadStream uploadStream,
java.nio.ByteBuffer buffer,
SingleResultCallback<java.lang.Void> callback) |
private void |
readAndWriteOutputStream(AsyncOutputStream destination,
GridFSDownloadStream downloadStream,
java.nio.ByteBuffer buffer,
long amountRead,
SingleResultCallback<java.lang.Long> callback) |
void |
rename(BsonValue id,
java.lang.String newFilename,
SingleResultCallback<java.lang.Void> callback)
Renames the stored file with the specified
id. |
void |
rename(ClientSession clientSession,
BsonValue id,
java.lang.String newFilename,
SingleResultCallback<java.lang.Void> callback)
Renames the stored file with the specified
id. |
void |
rename(ClientSession clientSession,
ObjectId id,
java.lang.String newFilename,
SingleResultCallback<java.lang.Void> callback)
Renames the stored file with the specified
id. |
void |
rename(ObjectId id,
java.lang.String newFilename,
SingleResultCallback<java.lang.Void> callback)
Renames the stored file with the specified
id. |
void |
uploadFromStream(BsonValue id,
java.lang.String filename,
AsyncInputStream source,
GridFSUploadOptions options,
SingleResultCallback<java.lang.Void> callback)
Uploads the contents of the given
AsyncInputStream to a GridFS bucket. |
void |
uploadFromStream(BsonValue id,
java.lang.String filename,
AsyncInputStream source,
SingleResultCallback<java.lang.Void> callback)
Uploads the contents of the given
AsyncInputStream to a GridFS bucket. |
void |
uploadFromStream(ClientSession clientSession,
BsonValue id,
java.lang.String filename,
AsyncInputStream source,
GridFSUploadOptions options,
SingleResultCallback<java.lang.Void> callback)
Uploads the contents of the given
AsyncInputStream to a GridFS bucket. |
void |
uploadFromStream(ClientSession clientSession,
BsonValue id,
java.lang.String filename,
AsyncInputStream source,
SingleResultCallback<java.lang.Void> callback)
Uploads the contents of the given
AsyncInputStream to a GridFS bucket. |
void |
uploadFromStream(ClientSession clientSession,
java.lang.String filename,
AsyncInputStream source,
GridFSUploadOptions options,
SingleResultCallback<ObjectId> callback)
Uploads the contents of the given
AsyncInputStream to a GridFS bucket. |
void |
uploadFromStream(ClientSession clientSession,
java.lang.String filename,
AsyncInputStream source,
SingleResultCallback<ObjectId> callback)
Uploads the contents of the given
AsyncInputStream to a GridFS bucket. |
void |
uploadFromStream(java.lang.String filename,
AsyncInputStream source,
GridFSUploadOptions options,
SingleResultCallback<ObjectId> callback)
Uploads the contents of the given
AsyncInputStream to a GridFS bucket. |
void |
uploadFromStream(java.lang.String filename,
AsyncInputStream source,
SingleResultCallback<ObjectId> callback)
Uploads the contents of the given
AsyncInputStream to a GridFS bucket. |
GridFSBucket |
withChunkSizeBytes(int chunkSizeBytes)
Create a new GridFSBucket instance with a new chunk size in bytes.
|
GridFSBucket |
withReadConcern(ReadConcern readConcern)
Create a new MongoDatabase instance with a different read concern.
|
GridFSBucket |
withReadPreference(ReadPreference readPreference)
Create a new GridFSBucket instance with a different read preference.
|
GridFSBucket |
withWriteConcern(WriteConcern writeConcern)
Create a new GridFSBucket instance with a different write concern.
|
private static final Logger LOGGER
private static final int DEFAULT_CHUNKSIZE_BYTES
private static final int DEFAULT_BUFFER_SIZE
private final java.lang.String bucketName
private final int chunkSizeBytes
private final MongoCollection<GridFSFile> filesCollection
private final MongoCollection<Document> chunksCollection
GridFSBucketImpl(MongoDatabase database)
GridFSBucketImpl(MongoDatabase database, java.lang.String bucketName)
GridFSBucketImpl(java.lang.String bucketName,
int chunkSizeBytes,
MongoCollection<GridFSFile> filesCollection,
MongoCollection<Document> chunksCollection)
public java.lang.String getBucketName()
GridFSBucketgetBucketName in interface GridFSBucketpublic int getChunkSizeBytes()
GridFSBucketgetChunkSizeBytes in interface GridFSBucketpublic ReadPreference getReadPreference()
GridFSBucketgetReadPreference in interface GridFSBucketReadPreferencepublic WriteConcern getWriteConcern()
GridFSBucketgetWriteConcern in interface GridFSBucketWriteConcernpublic ReadConcern getReadConcern()
GridFSBucketgetReadConcern in interface GridFSBucketReadConcernpublic GridFSBucket withChunkSizeBytes(int chunkSizeBytes)
GridFSBucketwithChunkSizeBytes in interface GridFSBucketchunkSizeBytes - the new chunk size in bytes.public GridFSBucket withReadPreference(ReadPreference readPreference)
GridFSBucketwithReadPreference in interface GridFSBucketreadPreference - the new ReadPreference for the databasepublic GridFSBucket withWriteConcern(WriteConcern writeConcern)
GridFSBucketwithWriteConcern in interface GridFSBucketwriteConcern - the new WriteConcern for the databasepublic GridFSBucket withReadConcern(ReadConcern readConcern)
GridFSBucketwithReadConcern in interface GridFSBucketreadConcern - the new ReadConcern for the databasepublic GridFSUploadStream openUploadStream(java.lang.String filename)
GridFSBucketAs the application writes the contents to the returned Stream, the contents are uploaded as chunks in the chunks collection. When the application signals it is done writing the contents of the file by calling close on the returned Stream, a files collection document is created in the files collection.
openUploadStream in interface GridFSBucketfilename - the filename for the streampublic GridFSUploadStream openUploadStream(java.lang.String filename, GridFSUploadOptions options)
GridFSBucketAs the application writes the contents to the returned Stream, the contents are uploaded as chunks in the chunks collection. When the application signals it is done writing the contents of the file by calling close on the returned Stream, a files collection document is created in the files collection.
openUploadStream in interface GridFSBucketfilename - the filename for the streamoptions - the GridFSUploadOptionspublic GridFSUploadStream openUploadStream(BsonValue id, java.lang.String filename)
GridFSBucketAs the application writes the contents to the returned Stream, the contents are uploaded as chunks in the chunks collection. When the application signals it is done writing the contents of the file by calling close on the returned Stream, a files collection document is created in the files collection.
openUploadStream in interface GridFSBucketid - the custom id value of the filefilename - the filename for the streampublic GridFSUploadStream openUploadStream(BsonValue id, java.lang.String filename, GridFSUploadOptions options)
GridFSBucketAs the application writes the contents to the returned Stream, the contents are uploaded as chunks in the chunks collection. When the application signals it is done writing the contents of the file by calling close on the returned Stream, a files collection document is created in the files collection.
openUploadStream in interface GridFSBucketid - the custom id value of the filefilename - the filename for the streamoptions - the GridFSUploadOptionspublic GridFSUploadStream openUploadStream(ClientSession clientSession, java.lang.String filename)
GridFSBucketAs the application writes the contents to the returned Stream, the contents are uploaded as chunks in the chunks collection. When the application signals it is done writing the contents of the file by calling close on the returned Stream, a files collection document is created in the files collection.
openUploadStream in interface GridFSBucketclientSession - the client session with which to associate this operationfilename - the filename for the streampublic GridFSUploadStream openUploadStream(ClientSession clientSession, java.lang.String filename, GridFSUploadOptions options)
GridFSBucketAs the application writes the contents to the returned Stream, the contents are uploaded as chunks in the chunks collection. When the application signals it is done writing the contents of the file by calling close on the returned Stream, a files collection document is created in the files collection.
openUploadStream in interface GridFSBucketclientSession - the client session with which to associate this operationfilename - the filename for the streamoptions - the GridFSUploadOptionspublic GridFSUploadStream openUploadStream(ClientSession clientSession, BsonValue id, java.lang.String filename)
GridFSBucketAs the application writes the contents to the returned Stream, the contents are uploaded as chunks in the chunks collection. When the application signals it is done writing the contents of the file by calling close on the returned Stream, a files collection document is created in the files collection.
openUploadStream in interface GridFSBucketclientSession - the client session with which to associate this operationid - the custom id value of the filefilename - the filename for the streampublic GridFSUploadStream openUploadStream(ClientSession clientSession, BsonValue id, java.lang.String filename, GridFSUploadOptions options)
GridFSBucketAs the application writes the contents to the returned Stream, the contents are uploaded as chunks in the chunks collection. When the application signals it is done writing the contents of the file by calling close on the returned Stream, a files collection document is created in the files collection.
openUploadStream in interface GridFSBucketclientSession - the client session with which to associate this operationid - the custom id value of the filefilename - the filename for the streamoptions - the GridFSUploadOptionsprivate GridFSUploadStream createGridFSUploadStream(ClientSession clientSession, BsonValue id, java.lang.String filename, GridFSUploadOptions options)
public void uploadFromStream(java.lang.String filename,
AsyncInputStream source,
SingleResultCallback<ObjectId> callback)
GridFSBucketAsyncInputStream to a GridFS bucket.
Reads the contents of the user file from the source and uploads it as chunks in the chunks collection. After all the
chunks have been uploaded, it creates a files collection document for filename in the files collection.
uploadFromStream in interface GridFSBucketfilename - the filename for the streamsource - the Stream providing the file datacallback - with the ObjectId of the uploaded file.public void uploadFromStream(java.lang.String filename,
AsyncInputStream source,
GridFSUploadOptions options,
SingleResultCallback<ObjectId> callback)
GridFSBucketAsyncInputStream to a GridFS bucket.
Reads the contents of the user file from the source and uploads it as chunks in the chunks collection. After all the
chunks have been uploaded, it creates a files collection document for filename in the files collection.
uploadFromStream in interface GridFSBucketfilename - the filename for the streamsource - the Stream providing the file dataoptions - the GridFSUploadOptionscallback - with the ObjectId of the uploaded file.public void uploadFromStream(BsonValue id, java.lang.String filename, AsyncInputStream source, SingleResultCallback<java.lang.Void> callback)
GridFSBucketAsyncInputStream to a GridFS bucket.
Reads the contents of the user file from the source and uploads it as chunks in the chunks collection. After all the
chunks have been uploaded, it creates a files collection document for filename in the files collection.
uploadFromStream in interface GridFSBucketid - the custom id value of the filefilename - the filename for the streamsource - the Stream providing the file datacallback - with the ObjectId of the uploaded file.public void uploadFromStream(BsonValue id, java.lang.String filename, AsyncInputStream source, GridFSUploadOptions options, SingleResultCallback<java.lang.Void> callback)
GridFSBucketAsyncInputStream to a GridFS bucket.
Reads the contents of the user file from the source and uploads it as chunks in the chunks collection. After all the
chunks have been uploaded, it creates a files collection document for filename in the files collection.
uploadFromStream in interface GridFSBucketid - the custom id value of the filefilename - the filename for the streamsource - the Stream providing the file dataoptions - the GridFSUploadOptionscallback - with the ObjectId of the uploaded file.public void uploadFromStream(ClientSession clientSession, java.lang.String filename, AsyncInputStream source, SingleResultCallback<ObjectId> callback)
GridFSBucketAsyncInputStream to a GridFS bucket.
Reads the contents of the user file from the source and uploads it as chunks in the chunks collection. After all the
chunks have been uploaded, it creates a files collection document for filename in the files collection.
uploadFromStream in interface GridFSBucketclientSession - the client session with which to associate this operationfilename - the filename for the streamsource - the Stream providing the file datacallback - with the ObjectId of the uploaded file.public void uploadFromStream(ClientSession clientSession, java.lang.String filename, AsyncInputStream source, GridFSUploadOptions options, SingleResultCallback<ObjectId> callback)
GridFSBucketAsyncInputStream to a GridFS bucket.
Reads the contents of the user file from the source and uploads it as chunks in the chunks collection. After all the
chunks have been uploaded, it creates a files collection document for filename in the files collection.
uploadFromStream in interface GridFSBucketclientSession - the client session with which to associate this operationfilename - the filename for the streamsource - the Stream providing the file dataoptions - the GridFSUploadOptionscallback - with the ObjectId of the uploaded file.public void uploadFromStream(ClientSession clientSession, BsonValue id, java.lang.String filename, AsyncInputStream source, SingleResultCallback<java.lang.Void> callback)
GridFSBucketAsyncInputStream to a GridFS bucket.
Reads the contents of the user file from the source and uploads it as chunks in the chunks collection. After all the
chunks have been uploaded, it creates a files collection document for filename in the files collection.
uploadFromStream in interface GridFSBucketclientSession - the client session with which to associate this operationid - the custom id value of the filefilename - the filename for the streamsource - the Stream providing the file datacallback - with the ObjectId of the uploaded file.public void uploadFromStream(ClientSession clientSession, BsonValue id, java.lang.String filename, AsyncInputStream source, GridFSUploadOptions options, SingleResultCallback<java.lang.Void> callback)
GridFSBucketAsyncInputStream to a GridFS bucket.
Reads the contents of the user file from the source and uploads it as chunks in the chunks collection. After all the
chunks have been uploaded, it creates a files collection document for filename in the files collection.
uploadFromStream in interface GridFSBucketclientSession - the client session with which to associate this operationid - the custom id value of the filefilename - the filename for the streamsource - the Stream providing the file dataoptions - the GridFSUploadOptionscallback - with the ObjectId of the uploaded file.private void executeUploadFromStream(ClientSession clientSession, BsonValue id, java.lang.String filename, AsyncInputStream source, GridFSUploadOptions options, SingleResultCallback<java.lang.Void> callback)
public GridFSDownloadStream openDownloadStream(ObjectId id)
GridFSBucketid.openDownloadStream in interface GridFSBucketid - the ObjectId of the file to be put into a stream.public GridFSDownloadStream openDownloadStream(BsonValue id)
GridFSBucketid.openDownloadStream in interface GridFSBucketid - the custom id value of the file, to be put into a stream.public GridFSDownloadStream openDownloadStream(java.lang.String filename)
GridFSBucketfilename.openDownloadStream in interface GridFSBucketfilename - the name of the file to be downloadedpublic GridFSDownloadStream openDownloadStream(java.lang.String filename, GridFSDownloadOptions options)
GridFSBucketfilename and the revision
in options.openDownloadStream in interface GridFSBucketfilename - the name of the file to be downloadedoptions - the download optionspublic GridFSDownloadStream openDownloadStream(ClientSession clientSession, ObjectId id)
GridFSBucketid.openDownloadStream in interface GridFSBucketclientSession - the client session with which to associate this operationid - the ObjectId of the file to be put into a stream.public GridFSDownloadStream openDownloadStream(ClientSession clientSession, BsonValue id)
GridFSBucketid.openDownloadStream in interface GridFSBucketclientSession - the client session with which to associate this operationid - the custom id value of the file, to be put into a stream.public GridFSDownloadStream openDownloadStream(ClientSession clientSession, java.lang.String filename)
GridFSBucketfilename.openDownloadStream in interface GridFSBucketclientSession - the client session with which to associate this operationfilename - the name of the file to be downloadedpublic GridFSDownloadStream openDownloadStream(ClientSession clientSession, java.lang.String filename, GridFSDownloadOptions options)
GridFSBucketfilename and the revision
in options.openDownloadStream in interface GridFSBucketclientSession - the client session with which to associate this operationfilename - the name of the file to be downloadedoptions - the download optionsprivate GridFSDownloadStream createGridFSDownloadStream(ClientSession clientSession, GridFSFindIterable gridFSFindIterable)
public void downloadToStream(java.lang.String filename,
AsyncOutputStream destination,
SingleResultCallback<java.lang.Long> callback)
GridFSBucketfilename and writes the contents to
the destination Stream.downloadToStream in interface GridFSBucketfilename - the name of the file to be downloadeddestination - the destination streamcallback - the callback that is completed once the file has been downloadedpublic void downloadToStream(java.lang.String filename,
AsyncOutputStream destination,
GridFSDownloadOptions options,
SingleResultCallback<java.lang.Long> callback)
GridFSBucketfilename and by the revision in options and writes the
contents to the destination Stream.downloadToStream in interface GridFSBucketfilename - the name of the file to be downloadeddestination - the destination streamoptions - the download optionscallback - the callback that is completed once the file has been downloadedpublic void downloadToStream(ObjectId id, AsyncOutputStream destination, SingleResultCallback<java.lang.Long> callback)
GridFSBucketid and writes the contents to the destination
AsyncOutputStream.downloadToStream in interface GridFSBucketid - the ObjectId of the file to be written to the destination streamdestination - the destination streamcallback - the callback that is completed once the file has been downloadedpublic void downloadToStream(BsonValue id, AsyncOutputStream destination, SingleResultCallback<java.lang.Long> callback)
GridFSBucketid and writes the contents to the destination
AsyncOutputStream.downloadToStream in interface GridFSBucketid - the custom id of the file, to be written to the destination streamdestination - the destination streamcallback - the callback that is completed once the file has been downloadedpublic void downloadToStream(ClientSession clientSession, ObjectId id, AsyncOutputStream destination, SingleResultCallback<java.lang.Long> callback)
GridFSBucketid and writes the contents to the destination
AsyncOutputStream.downloadToStream in interface GridFSBucketclientSession - the client session with which to associate this operationid - the ObjectId of the file to be written to the destination streamdestination - the destination streamcallback - the callback that is completed once the file has been downloadedpublic void downloadToStream(ClientSession clientSession, BsonValue id, AsyncOutputStream destination, SingleResultCallback<java.lang.Long> callback)
GridFSBucketid and writes the contents to the destination
AsyncOutputStream.downloadToStream in interface GridFSBucketclientSession - the client session with which to associate this operationid - the custom id of the file, to be written to the destination streamdestination - the destination streamcallback - the callback that is completed once the file has been downloadedpublic void downloadToStream(ClientSession clientSession, java.lang.String filename, AsyncOutputStream destination, SingleResultCallback<java.lang.Long> callback)
GridFSBucketfilename and writes the contents to
the destination Stream.downloadToStream in interface GridFSBucketclientSession - the client session with which to associate this operationfilename - the name of the file to be downloadeddestination - the destination streamcallback - the callback that is completed once the file has been downloadedpublic void downloadToStream(ClientSession clientSession, java.lang.String filename, AsyncOutputStream destination, GridFSDownloadOptions options, SingleResultCallback<java.lang.Long> callback)
GridFSBucketfilename and by the revision in options and writes the
contents to the destination Stream.downloadToStream in interface GridFSBucketclientSession - the client session with which to associate this operationfilename - the name of the file to be downloadeddestination - the destination streamoptions - the download optionscallback - the callback that is completed once the file has been downloadedpublic GridFSFindIterable find()
GridFSBucketfind in interface GridFSBucketpublic GridFSFindIterable find(Bson filter)
GridFSBucketBelow is an example of filtering against the filename and some nested metadata that can also be stored along with the file data:
Filters.and(Filters.eq("filename", "mongodb.png"), Filters.eq("metadata.contentType", "image/png"));
find in interface GridFSBucketfilter - the query filterFilterspublic GridFSFindIterable find(ClientSession clientSession)
GridFSBucketfind in interface GridFSBucketclientSession - the client session with which to associate this operationpublic GridFSFindIterable find(ClientSession clientSession, Bson filter)
GridFSBucketBelow is an example of filtering against the filename and some nested metadata that can also be stored along with the file data:
Filters.and(Filters.eq("filename", "mongodb.png"), Filters.eq("metadata.contentType", "image/png"));
find in interface GridFSBucketclientSession - the client session with which to associate this operationfilter - the query filterFilterspublic void delete(ObjectId id, SingleResultCallback<java.lang.Void> callback)
GridFSBucketid, delete this stored file's files collection document and associated chunks from a GridFS bucket.delete in interface GridFSBucketid - the ObjectId of the file to be deletedcallback - the callback that is completed once the file has been deletedpublic void delete(BsonValue id, SingleResultCallback<java.lang.Void> callback)
GridFSBucketid, delete this stored file's files collection document and associated chunks from a GridFS bucket.delete in interface GridFSBucketid - the ObjectId of the file to be deletedcallback - the callback that is completed once the file has been deletedpublic void delete(ClientSession clientSession, ObjectId id, SingleResultCallback<java.lang.Void> callback)
GridFSBucketid, delete this stored file's files collection document and associated chunks from a GridFS bucket.delete in interface GridFSBucketclientSession - the client session with which to associate this operationid - the ObjectId of the file to be deletedcallback - the callback that is completed once the file has been deletedpublic void delete(ClientSession clientSession, BsonValue id, SingleResultCallback<java.lang.Void> callback)
GridFSBucketid, delete this stored file's files collection document and associated chunks from a GridFS bucket.delete in interface GridFSBucketclientSession - the client session with which to associate this operationid - the ObjectId of the file to be deletedcallback - the callback that is completed once the file has been deletedprivate void executeDelete(ClientSession clientSession, BsonValue id, SingleResultCallback<java.lang.Void> callback)
public void rename(ObjectId id, java.lang.String newFilename, SingleResultCallback<java.lang.Void> callback)
GridFSBucketid.rename in interface GridFSBucketid - the id of the file in the files collection to renamenewFilename - the new filename for the filecallback - the callback that is completed once the file has been renamedpublic void rename(BsonValue id, java.lang.String newFilename, SingleResultCallback<java.lang.Void> callback)
GridFSBucketid.rename in interface GridFSBucketid - the id of the file in the files collection to renamenewFilename - the new filename for the filecallback - the callback that is completed once the file has been renamedpublic void rename(ClientSession clientSession, ObjectId id, java.lang.String newFilename, SingleResultCallback<java.lang.Void> callback)
GridFSBucketid.rename in interface GridFSBucketclientSession - the client session with which to associate this operationid - the id of the file in the files collection to renamenewFilename - the new filename for the filecallback - the callback that is completed once the file has been renamedpublic void rename(ClientSession clientSession, BsonValue id, java.lang.String newFilename, SingleResultCallback<java.lang.Void> callback)
GridFSBucketid.rename in interface GridFSBucketclientSession - the client session with which to associate this operationid - the id of the file in the files collection to renamenewFilename - the new filename for the filecallback - the callback that is completed once the file has been renamedprivate void executeRename(ClientSession clientSession, BsonValue id, java.lang.String newFilename, SingleResultCallback<java.lang.Void> callback)
public void drop(SingleResultCallback<java.lang.Void> callback)
GridFSBucketdrop in interface GridFSBucketcallback - the callback that is completed once the collection has been droppedpublic void drop(ClientSession clientSession, SingleResultCallback<java.lang.Void> callback)
GridFSBucketdrop in interface GridFSBucketclientSession - the client session with which to associate this operationcallback - the callback that is completed once the collection has been droppedprivate void executeDrop(ClientSession clientSession, SingleResultCallback<java.lang.Void> callback)
private GridFSFindIterable createGridFSFindIterable(ClientSession clientSession, Bson filter)
private GridFSFindIterable createGridFSFindIterable(ClientSession clientSession, java.lang.String filename, GridFSDownloadOptions options)
private FindIterable<GridFSFile> createFindIterable(ClientSession clientSession, Bson filter)
private static MongoCollection<GridFSFile> getFilesCollection(MongoDatabase database, java.lang.String bucketName)
private static MongoCollection<Document> getChunksCollection(MongoDatabase database, java.lang.String bucketName)
private void downloadToAsyncOutputStream(GridFSDownloadStream downloadStream, AsyncOutputStream destination, SingleResultCallback<java.lang.Long> callback)
private void readAndWriteInputStream(AsyncInputStream source, GridFSUploadStream uploadStream, java.nio.ByteBuffer buffer, SingleResultCallback<java.lang.Void> callback)
private void readAndWriteOutputStream(AsyncOutputStream destination, GridFSDownloadStream downloadStream, java.nio.ByteBuffer buffer, long amountRead, SingleResultCallback<java.lang.Long> callback)