Interface GridFSBucket
-
@ThreadSafe public interface GridFSBucket
Represents a GridFS Bucket- Since:
- 1.3
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description org.reactivestreams.Publisher<Void>delete(ClientSession clientSession, BsonValue id)Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.org.reactivestreams.Publisher<Void>delete(ClientSession clientSession, ObjectId id)Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.org.reactivestreams.Publisher<Void>delete(BsonValue id)Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.org.reactivestreams.Publisher<Void>delete(ObjectId id)Given aid, delete this stored file's files collection document and associated chunks from a GridFS bucket.GridFSDownloadPublisherdownloadToPublisher(ClientSession clientSession, String filename)Downloads the contents of the latest version of the stored file specified byfilenameinto thePublisher.GridFSDownloadPublisherdownloadToPublisher(ClientSession clientSession, String filename, GridFSDownloadOptions options)Downloads the contents of the stored file specified byfilenameand by the revision inoptionsinto thePublisher.GridFSDownloadPublisherdownloadToPublisher(ClientSession clientSession, BsonValue id)Downloads the contents of the stored file specified byidinto thePublisher.GridFSDownloadPublisherdownloadToPublisher(ClientSession clientSession, ObjectId id)Downloads the contents of the stored file specified byidinto thePublisher.GridFSDownloadPublisherdownloadToPublisher(String filename)Downloads the contents of the stored file specified byfilenameinto thePublisher.GridFSDownloadPublisherdownloadToPublisher(String filename, GridFSDownloadOptions options)Downloads the contents of the stored file specified byfilenameand by the revision inoptionsinto thePublisher.GridFSDownloadPublisherdownloadToPublisher(BsonValue id)Downloads the contents of the stored file specified byidinto thePublisher.GridFSDownloadPublisherdownloadToPublisher(ObjectId id)Downloads the contents of the stored file specified byidinto thePublisher.org.reactivestreams.Publisher<Void>drop()Drops the data associated with this bucket from the database.org.reactivestreams.Publisher<Void>drop(ClientSession clientSession)Drops the data associated with this bucket from the database.GridFSFindPublisherfind()Finds all documents in the files collection.GridFSFindPublisherfind(ClientSession clientSession)Finds all documents in the files collection.GridFSFindPublisherfind(ClientSession clientSession, Bson filter)Finds all documents in the collection that match the filter.GridFSFindPublisherfind(Bson filter)Finds all documents in the collection that match the filter.StringgetBucketName()The bucket name.intgetChunkSizeBytes()Sets the chunk size in bytes.ReadConcerngetReadConcern()Get the read concern for the GridFSBucket.ReadPreferencegetReadPreference()Get the read preference for the GridFSBucket.WriteConcerngetWriteConcern()Get the write concern for the GridFSBucket.org.reactivestreams.Publisher<Void>rename(ClientSession clientSession, BsonValue id, String newFilename)Renames the stored file with the specifiedid.org.reactivestreams.Publisher<Void>rename(ClientSession clientSession, ObjectId id, String newFilename)Renames the stored file with the specifiedid.org.reactivestreams.Publisher<Void>rename(BsonValue id, String newFilename)Renames the stored file with the specifiedid.org.reactivestreams.Publisher<Void>rename(ObjectId id, String newFilename)Renames the stored file with the specifiedid.GridFSUploadPublisher<ObjectId>uploadFromPublisher(ClientSession clientSession, String filename, org.reactivestreams.Publisher<ByteBuffer> source)Uploads the contents of the givenPublisherto a GridFS bucket.GridFSUploadPublisher<ObjectId>uploadFromPublisher(ClientSession clientSession, String filename, org.reactivestreams.Publisher<ByteBuffer> source, GridFSUploadOptions options)Uploads the contents of the givenPublisherto a GridFS bucket.GridFSUploadPublisher<Void>uploadFromPublisher(ClientSession clientSession, BsonValue id, String filename, org.reactivestreams.Publisher<ByteBuffer> source)Uploads the contents of the givenPublisherto a GridFS bucket.GridFSUploadPublisher<Void>uploadFromPublisher(ClientSession clientSession, BsonValue id, String filename, org.reactivestreams.Publisher<ByteBuffer> source, GridFSUploadOptions options)Uploads the contents of the givenPublisherto a GridFS bucket.GridFSUploadPublisher<ObjectId>uploadFromPublisher(String filename, org.reactivestreams.Publisher<ByteBuffer> source)Uploads the contents of the givenPublisherto a GridFS bucket.GridFSUploadPublisher<ObjectId>uploadFromPublisher(String filename, org.reactivestreams.Publisher<ByteBuffer> source, GridFSUploadOptions options)Uploads the contents of the givenPublisherto a GridFS bucket.GridFSUploadPublisher<Void>uploadFromPublisher(BsonValue id, String filename, org.reactivestreams.Publisher<ByteBuffer> source)Uploads the contents of the givenPublisherto a GridFS bucket.GridFSUploadPublisher<Void>uploadFromPublisher(BsonValue id, String filename, org.reactivestreams.Publisher<ByteBuffer> source, GridFSUploadOptions options)Uploads the contents of the givenPublisherto a GridFS bucket.GridFSBucketwithChunkSizeBytes(int chunkSizeBytes)Create a new GridFSBucket instance with a new chunk size in bytes.GridFSBucketwithReadConcern(ReadConcern readConcern)Create a new MongoDatabase instance with a different read concern.GridFSBucketwithReadPreference(ReadPreference readPreference)Create a new GridFSBucket instance with a different read preference.GridFSBucketwithWriteConcern(WriteConcern writeConcern)Create a new GridFSBucket instance with a different write concern.
-
-
-
Method Detail
-
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
WriteConcern getWriteConcern()
Get the write concern for the GridFSBucket.- Returns:
- the
WriteConcern
-
getReadPreference
ReadPreference getReadPreference()
Get the read preference for the GridFSBucket.- Returns:
- the
ReadPreference
-
getReadConcern
ReadConcern getReadConcern()
Get the read concern for the GridFSBucket.- Returns:
- the
ReadConcern - MongoDB documentation
- Read Concern
- Since server release
- 3.2
-
withChunkSizeBytes
GridFSBucket withChunkSizeBytes(int chunkSizeBytes)
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
GridFSBucket withReadPreference(ReadPreference readPreference)
Create a new GridFSBucket instance with a different read preference.- Parameters:
readPreference- the newReadPreferencefor the database- Returns:
- a new GridFSBucket instance with the different readPreference
-
withWriteConcern
GridFSBucket withWriteConcern(WriteConcern writeConcern)
Create a new GridFSBucket instance with a different write concern.- Parameters:
writeConcern- the newWriteConcernfor the database- Returns:
- a new GridFSBucket instance with the different writeConcern
-
withReadConcern
GridFSBucket withReadConcern(ReadConcern readConcern)
Create a new MongoDatabase instance with a different read concern.- Parameters:
readConcern- the newReadConcernfor the database- Returns:
- a new GridFSBucket instance with the different ReadConcern
- MongoDB documentation
- Read Concern
- Since server release
- 3.2
-
uploadFromPublisher
GridFSUploadPublisher<ObjectId> uploadFromPublisher(String filename, org.reactivestreams.Publisher<ByteBuffer> source)
Uploads the contents of the givenPublisherto a GridFS bucket.Reads the contents of the user file from the
sourceand 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 filenamesource- the Publisher providing the file data- Returns:
- a Publisher with a single element, the ObjectId of the uploaded file.
- Since:
- 1.13
-
uploadFromPublisher
GridFSUploadPublisher<ObjectId> uploadFromPublisher(String filename, org.reactivestreams.Publisher<ByteBuffer> source, GridFSUploadOptions options)
Uploads the contents of the givenPublisherto a GridFS bucket.Reads the contents of the user file from the
sourceand 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 filenamesource- the Publisher providing the file dataoptions- the GridFSUploadOptions- Returns:
- a Publisher with a single element, the ObjectId of the uploaded file.
- Since:
- 1.13
-
uploadFromPublisher
GridFSUploadPublisher<Void> uploadFromPublisher(BsonValue id, String filename, org.reactivestreams.Publisher<ByteBuffer> source)
Uploads the contents of the givenPublisherto a GridFS bucket.Reads the contents of the user file from the
sourceand 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:
id- the custom id value of the filefilename- the filenamesource- the Publisher providing the file data- Returns:
- a Publisher with a single element, representing when the successful upload of the source.
- Since:
- 1.13
-
uploadFromPublisher
GridFSUploadPublisher<Void> uploadFromPublisher(BsonValue id, String filename, org.reactivestreams.Publisher<ByteBuffer> source, GridFSUploadOptions options)
Uploads the contents of the givenPublisherto a GridFS bucket.Reads the contents of the user file from the
sourceand 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:
id- the custom id value of the filefilename- the filenamesource- the Publisher providing the file dataoptions- the GridFSUploadOptions- Returns:
- a Publisher with a single element, representing when the successful upload of the source.
- Since:
- 1.13
-
uploadFromPublisher
GridFSUploadPublisher<ObjectId> uploadFromPublisher(ClientSession clientSession, String filename, org.reactivestreams.Publisher<ByteBuffer> source)
Uploads the contents of the givenPublisherto a GridFS bucket.Reads the contents of the user file from the
sourceand 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:
clientSession- the client session with which to associate this operationfilename- the filenamesource- the Publisher providing the file data- Returns:
- a Publisher with a single element, the ObjectId of the uploaded file.
- Since:
- 1.13
- Since server release
- 3.6
-
uploadFromPublisher
GridFSUploadPublisher<ObjectId> uploadFromPublisher(ClientSession clientSession, String filename, org.reactivestreams.Publisher<ByteBuffer> source, GridFSUploadOptions options)
Uploads the contents of the givenPublisherto a GridFS bucket.Reads the contents of the user file from the
sourceand 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:
clientSession- the client session with which to associate this operationfilename- the filenamesource- the Publisher providing the file dataoptions- the GridFSUploadOptions- Returns:
- a Publisher with a single element, the ObjectId of the uploaded file.
- Since:
- 1.13
- Since server release
- 3.6
-
uploadFromPublisher
GridFSUploadPublisher<Void> uploadFromPublisher(ClientSession clientSession, BsonValue id, String filename, org.reactivestreams.Publisher<ByteBuffer> source)
Uploads the contents of the givenPublisherto a GridFS bucket.Reads the contents of the user file from the
sourceand 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:
clientSession- the client session with which to associate this operationid- the custom id value of the filefilename- the filenamesource- the Publisher providing the file data- Returns:
- a Publisher with a single element, representing when the successful upload of the source.
- Since:
- 1.13
- Since server release
- 3.6
-
uploadFromPublisher
GridFSUploadPublisher<Void> uploadFromPublisher(ClientSession clientSession, BsonValue id, String filename, org.reactivestreams.Publisher<ByteBuffer> source, GridFSUploadOptions options)
Uploads the contents of the givenPublisherto a GridFS bucket.Reads the contents of the user file from the
sourceand 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:
clientSession- the client session with which to associate this operationid- the custom id value of the filefilename- the filenamesource- the Publisher providing the file dataoptions- the GridFSUploadOptions- Returns:
- a Publisher with a single element, representing when the successful upload of the source.
- Since:
- 1.13
- Since server release
- 3.6
-
downloadToPublisher
GridFSDownloadPublisher downloadToPublisher(ObjectId id)
Downloads the contents of the stored file specified byidinto thePublisher.- Parameters:
id- the ObjectId of the file to be written to the destination Publisher- Returns:
- a Publisher with a single element, representing the amount of data written
- Since:
- 1.13
-
downloadToPublisher
GridFSDownloadPublisher downloadToPublisher(BsonValue id)
Downloads the contents of the stored file specified byidinto thePublisher.- Parameters:
id- the custom id of the file, to be written to the destination Publisher- Returns:
- a Publisher with a single element, representing the amount of data written
- Since:
- 1.13
-
downloadToPublisher
GridFSDownloadPublisher downloadToPublisher(String filename)
Downloads the contents of the stored file specified byfilenameinto thePublisher.- Parameters:
filename- the name of the file to be downloaded- Returns:
- a Publisher with a single element, representing the amount of data written
- Since:
- 1.13
-
downloadToPublisher
GridFSDownloadPublisher downloadToPublisher(String filename, GridFSDownloadOptions options)
Downloads the contents of the stored file specified byfilenameand by the revision inoptionsinto thePublisher.- Parameters:
filename- the name of the file to be downloadedoptions- the download options- Returns:
- a Publisher with a single element, representing the amount of data written
- Since:
- 1.13
-
downloadToPublisher
GridFSDownloadPublisher downloadToPublisher(ClientSession clientSession, ObjectId id)
Downloads the contents of the stored file specified byidinto thePublisher.- Parameters:
clientSession- the client session with which to associate this operationid- the ObjectId of the file to be written to the destination Publisher- Returns:
- a Publisher with a single element, representing the amount of data written
- Since:
- 1.13
- Since server release
- 3.6
-
downloadToPublisher
GridFSDownloadPublisher downloadToPublisher(ClientSession clientSession, BsonValue id)
Downloads the contents of the stored file specified byidinto thePublisher.- Parameters:
clientSession- the client session with which to associate this operationid- the custom id of the file, to be written to the destination Publisher- Returns:
- a Publisher with a single element, representing the amount of data written
- Since:
- 1.13
- Since server release
- 3.6
-
downloadToPublisher
GridFSDownloadPublisher downloadToPublisher(ClientSession clientSession, String filename)
Downloads the contents of the latest version of the stored file specified byfilenameinto thePublisher.- Parameters:
clientSession- the client session with which to associate this operationfilename- the name of the file to be downloaded- Returns:
- a Publisher with a single element, representing the amount of data written
- Since:
- 1.13
- Since server release
- 3.6
-
downloadToPublisher
GridFSDownloadPublisher downloadToPublisher(ClientSession clientSession, String filename, GridFSDownloadOptions options)
Downloads the contents of the stored file specified byfilenameand by the revision inoptionsinto thePublisher.- Parameters:
clientSession- the client session with which to associate this operationfilename- the name of the file to be downloadedoptions- the download options- Returns:
- a Publisher with a single element, representing the amount of data written
- Since:
- 1.13
- Since server release
- 3.6
-
find
GridFSFindPublisher find()
Finds all documents in the files collection.- Returns:
- the GridFS find iterable interface
- MongoDB documentation
- Find
-
find
GridFSFindPublisher find(Bson filter)
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
GridFSFindPublisher find(ClientSession clientSession)
Finds all documents in the files collection.
-
find
GridFSFindPublisher find(ClientSession clientSession, Bson filter)
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"));
-
delete
org.reactivestreams.Publisher<Void> delete(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- Returns:
- a publisher with a single element, representing that the file has been deleted
-
delete
org.reactivestreams.Publisher<Void> delete(BsonValue 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- Returns:
- a publisher with a single element, representing that the file has been deleted
-
delete
org.reactivestreams.Publisher<Void> delete(ClientSession clientSession, ObjectId id)
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- Returns:
- a publisher with a single element, representing that the file has been deleted
- Since:
- 1.7
- Since server release
- 3.6
-
delete
org.reactivestreams.Publisher<Void> delete(ClientSession clientSession, BsonValue id)
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- Returns:
- a publisher with a single element, representing that the file has been deleted
- Since:
- 1.7
- Since server release
- 3.6
-
rename
org.reactivestreams.Publisher<Void> rename(ObjectId id, String newFilename)
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- Returns:
- a publisher with a single element, representing that the file has been renamed
-
rename
org.reactivestreams.Publisher<Void> rename(BsonValue id, String newFilename)
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- Returns:
- a publisher with a single element, representing that the file has been renamed
-
rename
org.reactivestreams.Publisher<Void> rename(ClientSession clientSession, ObjectId id, String newFilename)
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- Returns:
- a publisher with a single element, representing that the file has been renamed
- Since:
- 1.7
- Since server release
- 3.6
-
rename
org.reactivestreams.Publisher<Void> rename(ClientSession clientSession, BsonValue id, String newFilename)
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- Returns:
- a publisher with a single element, representing that the file has been renamed
- Since:
- 1.7
- Since server release
- 3.6
-
drop
org.reactivestreams.Publisher<Void> drop()
Drops the data associated with this bucket from the database.- Returns:
- a publisher with a single element, representing that the collections have been dropped
-
drop
org.reactivestreams.Publisher<Void> drop(ClientSession clientSession)
Drops the data associated with this bucket from the database.- Parameters:
clientSession- the client session with which to associate this operation- Returns:
- a publisher with a single element, representing that the collections have been dropped
- Since:
- 1.7
- Since server release
- 3.6
-
-