Interface GridFSBucket
- Since:
- 3.1
-
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(ClientSession clientSession, org.bson.BsonValue id) Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.voiddelete(ClientSession clientSession, org.bson.types.ObjectId id) Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.voiddelete(org.bson.BsonValue id) Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.voiddelete(org.bson.types.ObjectId id) Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.voiddownloadToStream(ClientSession clientSession, String filename, OutputStream destination) Downloads the contents of the latest version of the stored file specified byfilenameand writes the contents to thedestinationStream.voiddownloadToStream(ClientSession clientSession, String filename, OutputStream destination, com.mongodb.client.gridfs.model.GridFSDownloadOptions options) Downloads the contents of the stored file specified byfilenameand by the revision inoptionsand writes the contents to thedestinationStream.voiddownloadToStream(ClientSession clientSession, org.bson.BsonValue id, OutputStream destination) Downloads the contents of the stored file specified byidand writes the contents to thedestinationStream.voiddownloadToStream(ClientSession clientSession, org.bson.types.ObjectId id, OutputStream destination) Downloads the contents of the stored file specified byidand writes the contents to thedestinationStream.voiddownloadToStream(String filename, OutputStream destination) Downloads the contents of the latest version of the stored file specified byfilenameand writes the contents to thedestinationStream.voiddownloadToStream(String filename, OutputStream destination, com.mongodb.client.gridfs.model.GridFSDownloadOptions options) Downloads the contents of the stored file specified byfilenameand by the revision inoptionsand writes the contents to thedestinationStream.voiddownloadToStream(org.bson.BsonValue id, OutputStream destination) Downloads the contents of the stored file specified byidand writes the contents to thedestinationStream.voiddownloadToStream(org.bson.types.ObjectId id, OutputStream destination) Downloads the contents of the stored file specified byidand writes the contents to thedestinationStream.voiddrop()Drops the data associated with this bucket from the database.voiddrop(ClientSession clientSession) Drops the data associated with this bucket from the database.find()Finds all documents in the files collection.find(ClientSession clientSession) Finds all documents in the files collection.find(ClientSession clientSession, org.bson.conversions.Bson filter) Finds all documents in the collection that match the filter.find(org.bson.conversions.Bson filter) Finds all documents in the collection that match the filter.The bucket name.intSets the chunk size in bytes.com.mongodb.ReadConcernGet the read concern for the GridFSBucket.com.mongodb.ReadPreferenceGet the read preference for the GridFSBucket.getTimeout(TimeUnit timeUnit) The time limit for the full execution of an operation.com.mongodb.WriteConcernGet the write concern for the GridFSBucket.openDownloadStream(ClientSession clientSession, String filename) Opens a Stream from which the application can read the contents of the latest version of the stored file specified by thefilename.openDownloadStream(ClientSession clientSession, String filename, com.mongodb.client.gridfs.model.GridFSDownloadOptions options) Opens a Stream from which the application can read the contents of the stored file specified byfilenameand the revision inoptions.openDownloadStream(ClientSession clientSession, org.bson.BsonValue id) Opens a Stream from which the application can read the contents of the stored file specified byid.openDownloadStream(ClientSession clientSession, org.bson.types.ObjectId id) Opens a Stream from which the application can read the contents of the stored file specified byid.openDownloadStream(String filename) Opens a Stream from which the application can read the contents of the latest version of the stored file specified by thefilename.openDownloadStream(String filename, com.mongodb.client.gridfs.model.GridFSDownloadOptions options) Opens a Stream from which the application can read the contents of the stored file specified byfilenameand the revision inoptions.openDownloadStream(org.bson.BsonValue id) Opens a Stream from which the application can read the contents of the stored file specified byid.openDownloadStream(org.bson.types.ObjectId id) Opens a Stream from which the application can read the contents of the stored file specified byid.openUploadStream(ClientSession clientSession, String filename) Opens a Stream that the application can write the contents of the file to.openUploadStream(ClientSession clientSession, String filename, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Opens a Stream that the application can write the contents of the file to.openUploadStream(ClientSession clientSession, org.bson.BsonValue id, String filename) Opens a Stream that the application can write the contents of the file to.openUploadStream(ClientSession clientSession, org.bson.BsonValue id, String filename, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Opens a Stream that the application can write the contents of the file to.openUploadStream(ClientSession clientSession, org.bson.types.ObjectId id, String filename) Opens a Stream that the application can write the contents of the file to.openUploadStream(String filename) Opens a Stream that the application can write the contents of the file to.openUploadStream(String filename, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Opens a Stream that the application can write the contents of the file to.openUploadStream(org.bson.BsonValue id, String filename) Opens a Stream that the application can write the contents of the file to.openUploadStream(org.bson.BsonValue id, String filename, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Opens a Stream that the application can write the contents of the file to.voidrename(ClientSession clientSession, org.bson.BsonValue id, String newFilename) Renames the stored file with the specifiedid.voidrename(ClientSession clientSession, org.bson.types.ObjectId id, String newFilename) Renames the stored file with the specifiedid.voidRenames the stored file with the specifiedid.voidRenames the stored file with the specifiedid.org.bson.types.ObjectIduploadFromStream(ClientSession clientSession, String filename, InputStream source) Uploads the contents of the givenInputStreamto a GridFS bucket.org.bson.types.ObjectIduploadFromStream(ClientSession clientSession, String filename, InputStream source, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Uploads the contents of the givenInputStreamto a GridFS bucket.voiduploadFromStream(ClientSession clientSession, org.bson.BsonValue id, String filename, InputStream source) Uploads the contents of the givenInputStreamto a GridFS bucket.voiduploadFromStream(ClientSession clientSession, org.bson.BsonValue id, String filename, InputStream source, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Uploads the contents of the givenInputStreamto a GridFS bucket.org.bson.types.ObjectIduploadFromStream(String filename, InputStream source) Uploads the contents of the givenInputStreamto a GridFS bucket.org.bson.types.ObjectIduploadFromStream(String filename, InputStream source, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Uploads the contents of the givenInputStreamto a GridFS bucket.voiduploadFromStream(org.bson.BsonValue id, String filename, InputStream source) Uploads the contents of the givenInputStreamto a GridFS bucket.voiduploadFromStream(org.bson.BsonValue id, String filename, InputStream source, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Uploads the contents of the givenInputStreamto a GridFS bucket.withChunkSizeBytes(int chunkSizeBytes) Create a new GridFSBucket instance with a new chunk size in bytes.withReadConcern(com.mongodb.ReadConcern readConcern) Create a new GridFSBucket instance with a different read concern.withReadPreference(com.mongodb.ReadPreference readPreference) Create a new GridFSBucket instance with a different read preference.withTimeout(long timeout, TimeUnit timeUnit) Create a new GridFSBucket instance with the set time limit for the full execution of an operation.withWriteConcern(com.mongodb.WriteConcern writeConcern) Create a new GridFSBucket instance with a different write concern.
-
Method Details
-
getBucketName
String getBucketName()The bucket name.- Returns:
- the bucket name
-
getChunkSizeBytes
int getChunkSizeBytes()Sets the chunk size in bytes. Defaults to 255.- Returns:
- the chunk size in bytes.
-
getWriteConcern
com.mongodb.WriteConcern getWriteConcern()Get the write concern for the GridFSBucket.- Returns:
- the
WriteConcern
-
getReadPreference
com.mongodb.ReadPreference getReadPreference()Get the read preference for the GridFSBucket.- Returns:
- the
ReadPreference
-
getReadConcern
com.mongodb.ReadConcern getReadConcern()Get the read concern for the GridFSBucket.- Returns:
- the
ReadConcern - Since:
- 3.2
- MongoDB documentation
- Read Concern
- Since server release
- 3.2
-
getTimeout
The time limit for the full execution of an operation.If not null the following deprecated options will be ignored:
waitQueueTimeoutMS,socketTimeoutMS,wTimeoutMS,maxTimeMSandmaxCommitTimeMSnullmeans that the timeout mechanism for operations will defer to using:waitQueueTimeoutMS: The maximum wait time in milliseconds that a thread may wait for a connection to become availablesocketTimeoutMS: How long a send or receive on a socket can take before timing out.wTimeoutMS: How long the server will wait for the write concern to be fulfilled before timing out.maxTimeMS: The cumulative time limit for processing operations on a cursor. See: cursor.maxTimeMS.maxCommitTimeMS: The maximum amount of time to allow a singlecommitTransactioncommand to execute. See:TransactionOptions.getMaxCommitTime(java.util.concurrent.TimeUnit).
0means infinite timeout.> 0The time limit to use for the full execution of an operation.
- Parameters:
timeUnit- the time unit- Returns:
- the timeout in the given time unit
- Since:
- 4.x
-
withChunkSizeBytes
Create a new GridFSBucket instance with a new chunk size in bytes.- Parameters:
chunkSizeBytes- the new chunk size in bytes.- Returns:
- a new GridFSBucket instance with the different chunk size in bytes
-
withReadPreference
Create a new GridFSBucket instance with a different read preference.- Parameters:
readPreference- the newReadPreferencefor the GridFSBucket- Returns:
- a new GridFSBucket instance with the different readPreference
-
withWriteConcern
Create a new GridFSBucket instance with a different write concern.- Parameters:
writeConcern- the newWriteConcernfor the GridFSBucket- Returns:
- a new GridFSBucket instance with the different writeConcern
-
withReadConcern
Create a new GridFSBucket instance with a different read concern.- Parameters:
readConcern- the newReadConcernfor the GridFSBucket- Returns:
- a new GridFSBucket instance with the different ReadConcern
- Since:
- 3.2
- MongoDB documentation
- Read Concern
- Since server release
- 3.2
-
withTimeout
Create a new GridFSBucket instance with the set time limit for the full execution of an operation.0means infinite timeout.> 0The time limit to use for the full execution of an operation.
- Parameters:
timeout- the timeout, which must be greater than or equal to 0timeUnit- the time unit- Returns:
- a new GridFSBucket instance with the set time limit for the full execution of an operation
- Since:
- 4.x
- See Also:
-
openUploadStream
Opens a Stream that the application can write the contents of the file to.As 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.
- Parameters:
filename- the filename for the stream- Returns:
- the GridFSUploadStream that provides the ObjectId for the file to be uploaded and the Stream to which the application will write the contents.
-
openUploadStream
GridFSUploadStream openUploadStream(String filename, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Opens a Stream that the application can write the contents of the file to.As 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.
- Parameters:
filename- the filename for the streamoptions- the GridFSUploadOptions- Returns:
- the GridFSUploadStream that provides the ObjectId for the file to be uploaded and the Stream to which the application will write the contents.
-
openUploadStream
Opens a Stream that the application can write the contents of the file to.As 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.
- Parameters:
id- the custom id value of the filefilename- the filename for the stream- Returns:
- the GridFSUploadStream that provides the ObjectId for the file to be uploaded and the Stream to which the application will write the contents.
- Since:
- 3.3
-
openUploadStream
GridFSUploadStream openUploadStream(org.bson.BsonValue id, String filename, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Opens a Stream that the application can write the contents of the file to.As 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.
- Parameters:
id- the custom id value of the filefilename- the filename for the streamoptions- the GridFSUploadOptions- Returns:
- the GridFSUploadStream that includes the _id for the file to be uploaded and the Stream to which the application will write the contents.
- Since:
- 3.3
-
openUploadStream
Opens a Stream that the application can write the contents of the file to.As 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.
- Parameters:
clientSession- the client session with which to associate this operationfilename- the filename for the stream- Returns:
- the GridFSUploadStream that provides the ObjectId for the file to be uploaded and the Stream to which the application will write the contents.
- Since:
- 3.6
- Since server release
- 3.6
-
openUploadStream
GridFSUploadStream openUploadStream(ClientSession clientSession, String filename, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Opens a Stream that the application can write the contents of the file to.As 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.
- Parameters:
clientSession- the client session with which to associate this operationfilename- the filename for the streamoptions- the GridFSUploadOptions- Returns:
- the GridFSUploadStream that provides the ObjectId for the file to be uploaded and the Stream to which the application will write the contents.
- Since:
- 3.6
- Since server release
- 3.6
-
openUploadStream
GridFSUploadStream openUploadStream(ClientSession clientSession, org.bson.BsonValue id, String filename) Opens a Stream that the application can write the contents of the file to.As 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.
- Parameters:
clientSession- the client session with which to associate this operationid- the custom id value of the filefilename- the filename for the stream- Returns:
- the GridFSUploadStream that provides the ObjectId for the file to be uploaded and the Stream to which the application will write the contents.
- Since:
- 3.6
- Since server release
- 3.6
-
openUploadStream
GridFSUploadStream openUploadStream(ClientSession clientSession, org.bson.types.ObjectId id, String filename) Opens a Stream that the application can write the contents of the file to.As 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.
- Parameters:
clientSession- the client session with which to associate this operationid- the custom id value of the filefilename- the filename for the stream- Returns:
- the GridFSUploadStream that provides the ObjectId for the file to be uploaded and the Stream to which the application will write the contents.
- Since:
- 3.6
- Since server release
- 3.6
-
openUploadStream
GridFSUploadStream openUploadStream(ClientSession clientSession, org.bson.BsonValue id, String filename, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Opens a Stream that the application can write the contents of the file to.As 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.
- Parameters:
clientSession- the client session with which to associate this operationid- the custom id value of the filefilename- the filename for the streamoptions- the GridFSUploadOptions- Returns:
- the GridFSUploadStream that includes the _id for the file to be uploaded and the Stream to which the application will write the contents.
- Since:
- 3.6
- Since server release
- 3.6
-
uploadFromStream
Uploads the contents of the givenInputStreamto a GridFS bucket.Reads the contents of the user file from the
Streamand uploads it as chunks in the chunks collection. After all the chunks have been uploaded, it creates a files collection document forfilenamein the files collection.- Parameters:
filename- the filename for the streamsource- the Stream providing the file data- Returns:
- the ObjectId of the uploaded file.
-
uploadFromStream
org.bson.types.ObjectId uploadFromStream(String filename, InputStream source, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Uploads the contents of the givenInputStreamto a GridFS bucket.Reads the contents of the user file from the
Streamand uploads it as chunks in the chunks collection. After all the chunks have been uploaded, it creates a files collection document forfilenamein the files collection.- Parameters:
filename- the filename for the streamsource- the Stream providing the file dataoptions- the GridFSUploadOptions- Returns:
- the ObjectId of the uploaded file.
-
uploadFromStream
Uploads the contents of the givenInputStreamto a GridFS bucket.Reads the contents of the user file from the
Streamand uploads it as chunks in the chunks collection. After all the chunks have been uploaded, it creates a files collection document forfilenamein the files collection.Note: When this
GridFSBucketis set with a operation timeout (via timeout inherited fromMongoDatabasesettings orwithTimeout(long, TimeUnit)), timeout breaches may occur due to theInputStreamlacking inherent read timeout support, which might extend the operation beyond the specified timeout limit.- Parameters:
id- the custom id value of the filefilename- the filename for the streamsource- the Stream providing the file data- Since:
- 3.3
-
uploadFromStream
void uploadFromStream(org.bson.BsonValue id, String filename, InputStream source, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Uploads the contents of the givenInputStreamto a GridFS bucket.Reads the contents of the user file from the
Streamand uploads it as chunks in the chunks collection. After all the chunks have been uploaded, it creates a files collection document forfilenamein the files collection.Note: When this
GridFSBucketis set with a operation timeout (via timeout inherited fromMongoDatabasesettings orwithTimeout(long, TimeUnit)), timeout breaches may occur due to theInputStreamlacking inherent read timeout support, which might extend the operation beyond the specified timeout limit.- Parameters:
id- the custom id value of the filefilename- the filename for the streamsource- the Stream providing the file dataoptions- the GridFSUploadOptions- Since:
- 3.3
-
uploadFromStream
org.bson.types.ObjectId uploadFromStream(ClientSession clientSession, String filename, InputStream source) Uploads the contents of the givenInputStreamto a GridFS bucket.Reads the contents of the user file from the
Streamand uploads it as chunks in the chunks collection. After all the chunks have been uploaded, it creates a files collection document forfilenamein the files collection.Note: When this
GridFSBucketis set with a operation timeout (via timeout inherited fromMongoDatabasesettings orwithTimeout(long, TimeUnit)), timeout breaches may occur due to theInputStreamlacking inherent read timeout support, which might extend the operation beyond the specified timeout limit.- Parameters:
clientSession- the client session with which to associate this operationfilename- the filename for the streamsource- the Stream providing the file data- Returns:
- the ObjectId of the uploaded file.
- Since:
- 3.6
- Since server release
- 3.6
-
uploadFromStream
org.bson.types.ObjectId uploadFromStream(ClientSession clientSession, String filename, InputStream source, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Uploads the contents of the givenInputStreamto a GridFS bucket.Reads the contents of the user file from the
Streamand uploads it as chunks in the chunks collection. After all the chunks have been uploaded, it creates a files collection document forfilenamein the files collection.Note: When this
GridFSBucketis set with a operation timeout (via timeout inherited fromMongoDatabasesettings orwithTimeout(long, TimeUnit)), timeout breaches may occur due to theInputStreamlacking inherent read timeout support, which might extend the operation beyond the specified timeout limit.- Parameters:
clientSession- the client session with which to associate this operationfilename- the filename for the streamsource- the Stream providing the file dataoptions- the GridFSUploadOptions- Returns:
- the ObjectId of the uploaded file.
- Since:
- 3.6
- Since server release
- 3.6
-
uploadFromStream
void uploadFromStream(ClientSession clientSession, org.bson.BsonValue id, String filename, InputStream source) Uploads the contents of the givenInputStreamto a GridFS bucket.Reads the contents of the user file from the
Streamand uploads it as chunks in the chunks collection. After all the chunks have been uploaded, it creates a files collection document forfilenamein the files collection.Note: When this
GridFSBucketis set with a operation timeout (via timeout inherited fromMongoDatabasesettings orwithTimeout(long, TimeUnit)), timeout breaches may occur due to theInputStreamlacking inherent read timeout support, which might extend the operation beyond the specified timeout limit.- Parameters:
clientSession- 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 data- Since:
- 3.6
- Since server release
- 3.6
-
uploadFromStream
void uploadFromStream(ClientSession clientSession, org.bson.BsonValue id, String filename, InputStream source, com.mongodb.client.gridfs.model.GridFSUploadOptions options) Uploads the contents of the givenInputStreamto a GridFS bucket.Reads the contents of the user file from the
Streamand uploads it as chunks in the chunks collection. After all the chunks have been uploaded, it creates a files collection document forfilenamein the files collection.Note: When this
GridFSBucketis set with a operation timeout (via timeout inherited fromMongoDatabasesettings orwithTimeout(long, TimeUnit)), timeout breaches may occur due to theInputStreamlacking inherent read timeout support, which might extend the operation beyond the specified timeout limit.- Parameters:
clientSession- 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 GridFSUploadOptions- Since:
- 3.6
- Since server release
- 3.6
-
openDownloadStream
Opens a Stream from which the application can read the contents of the stored file specified byid.- Parameters:
id- the ObjectId of the file to be put into a stream.- Returns:
- the stream
-
openDownloadStream
Opens a Stream from which the application can read the contents of the stored file specified byid.- Parameters:
id- the custom id value of the file, to be put into a stream.- Returns:
- the stream
-
openDownloadStream
Opens a Stream from which the application can read the contents of the latest version of the stored file specified by thefilename.- Parameters:
filename- the name of the file to be downloaded- Returns:
- the stream
- Since:
- 3.3
-
openDownloadStream
GridFSDownloadStream openDownloadStream(String filename, com.mongodb.client.gridfs.model.GridFSDownloadOptions options) Opens a Stream from which the application can read the contents of the stored file specified byfilenameand the revision inoptions.- Parameters:
filename- the name of the file to be downloadedoptions- the download options- Returns:
- the stream
- Since:
- 3.3
-
openDownloadStream
Opens a Stream from which the application can read the contents of the stored file specified byid.- Parameters:
clientSession- the client session with which to associate this operationid- the ObjectId of the file to be put into a stream.- Returns:
- the stream
- Since:
- 3.6
- Since server release
- 3.6
-
openDownloadStream
Opens a Stream from which the application can read the contents of the stored file specified byid.- Parameters:
clientSession- the client session with which to associate this operationid- the custom id value of the file, to be put into a stream.- Returns:
- the stream
- Since:
- 3.6
- Since server release
- 3.6
-
openDownloadStream
Opens a Stream from which the application can read the contents of the latest version of the stored file specified by thefilename.- Parameters:
clientSession- the client session with which to associate this operationfilename- the name of the file to be downloaded- Returns:
- the stream
- Since:
- 3.6
- Since server release
- 3.6
-
openDownloadStream
GridFSDownloadStream openDownloadStream(ClientSession clientSession, String filename, com.mongodb.client.gridfs.model.GridFSDownloadOptions options) Opens a Stream from which the application can read the contents of the stored file specified byfilenameand the revision inoptions.- Parameters:
clientSession- the client session with which to associate this operationfilename- the name of the file to be downloadedoptions- the download options- Returns:
- the stream
- Since:
- 3.6
- Since server release
- 3.6
-
downloadToStream
Downloads the contents of the stored file specified byidand writes the contents to thedestinationStream.- Parameters:
id- the ObjectId of the file to be written to the destination streamdestination- the destination stream. ItsOutputStream.flush()is not guaranteed to be called by this method.
-
downloadToStream
Downloads the contents of the stored file specified byidand writes the contents to thedestinationStream.- Parameters:
id- the custom id of the file, to be written to the destination streamdestination- the destination stream. ItsOutputStream.flush()is not guaranteed to be called by this method.
-
downloadToStream
Downloads the contents of the latest version of the stored file specified byfilenameand writes the contents to thedestinationStream.- Parameters:
filename- the name of the file to be downloadeddestination- the destination stream. ItsOutputStream.flush()is not guaranteed to be called by this method.- Since:
- 3.3
-
downloadToStream
void downloadToStream(String filename, OutputStream destination, com.mongodb.client.gridfs.model.GridFSDownloadOptions options) Downloads the contents of the stored file specified byfilenameand by the revision inoptionsand writes the contents to thedestinationStream.- Parameters:
filename- the name of the file to be downloadeddestination- the destination streamoptions- the download options. ItsOutputStream.flush()is not guaranteed to be called by this method.- Since:
- 3.3
-
downloadToStream
void downloadToStream(ClientSession clientSession, org.bson.types.ObjectId id, OutputStream destination) Downloads the contents of the stored file specified byidand writes the contents to thedestinationStream.- Parameters:
clientSession- the client session with which to associate this operationid- the ObjectId of the file to be written to the destination streamdestination- the destination stream. ItsOutputStream.flush()is not guaranteed to be called by this method.- Since:
- 3.6
- Since server release
- 3.6
-
downloadToStream
Downloads the contents of the stored file specified byidand writes the contents to thedestinationStream.- Parameters:
clientSession- the client session with which to associate this operationid- the custom id of the file, to be written to the destination streamdestination- the destination stream. ItsOutputStream.flush()is not guaranteed to be called by this method.- Since:
- 3.6
- Since server release
- 3.6
-
downloadToStream
Downloads the contents of the latest version of the stored file specified byfilenameand writes the contents to thedestinationStream.- Parameters:
clientSession- the client session with which to associate this operationfilename- the name of the file to be downloadeddestination- the destination stream. ItsOutputStream.flush()is not guaranteed to be called by this method.- Since:
- 3.6
- Since server release
- 3.6
-
downloadToStream
void downloadToStream(ClientSession clientSession, String filename, OutputStream destination, com.mongodb.client.gridfs.model.GridFSDownloadOptions options) Downloads the contents of the stored file specified byfilenameand by the revision inoptionsand writes the contents to thedestinationStream.- Parameters:
clientSession- the client session with which to associate this operationfilename- the name of the file to be downloadeddestination- the destination stream. ItsOutputStream.flush()is not guaranteed to be called by this method.options- the download options- Since:
- 3.6
- Since server release
- 3.6
-
find
GridFSFindIterable find()Finds all documents in the files collection.- Returns:
- the GridFS find iterable interface
- MongoDB documentation
- Find
-
find
Finds all documents in the collection that match the filter.Below 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"));- Parameters:
filter- the query filter- Returns:
- the GridFS find iterable interface
- See Also:
-
Filters
-
find
Finds all documents in the files collection. -
find
Finds all documents in the collection that match the filter.Below 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"));- Parameters:
clientSession- the client session with which to associate this operationfilter- the query filter- Returns:
- the GridFS find iterable interface
- Since:
- 3.6
- See Also:
-
Filters
- Since server release
- 3.6
-
delete
void delete(org.bson.types.ObjectId id) Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.- Parameters:
id- the ObjectId of the file to be deleted
-
delete
void delete(org.bson.BsonValue id) Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.- Parameters:
id- the id of the file to be deleted- Since:
- 3.3
-
delete
Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.- Parameters:
clientSession- the client session with which to associate this operationid- the ObjectId of the file to be deleted- Since:
- 3.6
- Since server release
- 3.6
-
delete
Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.- Parameters:
clientSession- the client session with which to associate this operationid- the id of the file to be deleted- Since:
- 3.6
- Since server release
- 3.6
-
rename
Renames the stored file with the specifiedid.- Parameters:
id- the id of the file in the files collection to renamenewFilename- the new filename for the file
-
rename
Renames the stored file with the specifiedid.- Parameters:
id- the id of the file in the files collection to renamenewFilename- the new filename for the file- Since:
- 3.3
-
rename
Renames the stored file with the specifiedid.- Parameters:
clientSession- 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 file- Since:
- 3.6
- Since server release
- 3.6
-
rename
Renames the stored file with the specifiedid.- Parameters:
clientSession- 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 file- Since:
- 3.6
- Since server release
- 3.6
-
drop
void drop()Drops the data associated with this bucket from the database. -
drop
Drops the data associated with this bucket from the database.- Parameters:
clientSession- the client session with which to associate this operation- Since:
- 3.6
- Since server release
- 3.6
-