@ThreadSafe public interface GridFSBucket
Modifier and Type | Method and Description |
---|---|
void |
delete(BsonValue id)
Given a
id , delete this stored file's files collection document and associated chunks from a GridFS bucket. |
void |
delete(ClientSession clientSession,
BsonValue id)
Given a
id , delete this stored file's files collection document and associated chunks from a GridFS bucket. |
void |
delete(ClientSession clientSession,
ObjectId id)
Given a
id , delete this stored file's files collection document and associated chunks from a GridFS bucket. |
void |
delete(ObjectId id)
Given a
id , delete this stored file's files collection document and associated chunks from a GridFS bucket. |
void |
downloadToStream(BsonValue id,
java.io.OutputStream destination)
Downloads the contents of the stored file specified by
id and writes the contents to the destination Stream. |
void |
downloadToStream(ClientSession clientSession,
BsonValue id,
java.io.OutputStream destination)
Downloads the contents of the stored file specified by
id and writes the contents to the destination Stream. |
void |
downloadToStream(ClientSession clientSession,
ObjectId id,
java.io.OutputStream destination)
Downloads the contents of the stored file specified by
id and writes the contents to the destination Stream. |
void |
downloadToStream(ClientSession clientSession,
java.lang.String filename,
java.io.OutputStream destination)
Downloads the contents of the latest version of the stored file specified by
filename and writes the contents to
the destination Stream. |
void |
downloadToStream(ClientSession clientSession,
java.lang.String filename,
java.io.OutputStream destination,
GridFSDownloadOptions options)
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(ObjectId id,
java.io.OutputStream destination)
Downloads the contents of the stored file specified by
id and writes the contents to the destination Stream. |
void |
downloadToStream(java.lang.String filename,
java.io.OutputStream destination)
Downloads the contents of the latest version of the stored file specified by
filename and writes the contents to
the destination Stream. |
void |
downloadToStream(java.lang.String filename,
java.io.OutputStream destination,
GridFSDownloadOptions options)
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 |
downloadToStreamByName(java.lang.String filename,
java.io.OutputStream destination)
Deprecated.
use
downloadToStream(String, OutputStream) instead. |
void |
downloadToStreamByName(java.lang.String filename,
java.io.OutputStream destination,
GridFSDownloadByNameOptions options)
Deprecated.
|
void |
drop()
Drops the data associated with this bucket from the database.
|
void |
drop(ClientSession clientSession)
Drops the data associated with this bucket from the database.
|
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.
|
int |
getChunkSizeBytes()
Sets the chunk size in bytes.
|
boolean |
getDisableMD5()
Returns true if computing MD5 checksums when uploading files is disabled.
|
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 Stream from which the application can read the contents of the stored file specified by
id . |
GridFSDownloadStream |
openDownloadStream(ClientSession clientSession,
BsonValue id)
Opens a Stream from which the application can read the contents of the stored file specified by
id . |
GridFSDownloadStream |
openDownloadStream(ClientSession clientSession,
ObjectId id)
Opens a Stream 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 Stream 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 . |
GridFSDownloadStream |
openDownloadStreamByName(java.lang.String filename)
Deprecated.
use
openDownloadStream(String) instead. |
GridFSDownloadStream |
openDownloadStreamByName(java.lang.String filename,
GridFSDownloadByNameOptions options)
Deprecated.
use
openDownloadStream(String, GridFSDownloadOptions) instead. |
GridFSUploadStream |
openUploadStream(BsonValue id,
java.lang.String filename)
Opens a Stream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(BsonValue id,
java.lang.String filename,
GridFSUploadOptions options)
Opens a Stream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(ClientSession clientSession,
BsonValue id,
java.lang.String filename)
Opens a Stream 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 Stream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(ClientSession clientSession,
ObjectId id,
java.lang.String filename)
Opens a Stream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(ClientSession clientSession,
java.lang.String filename)
Opens a Stream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(ClientSession clientSession,
java.lang.String filename,
GridFSUploadOptions options)
Opens a Stream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(java.lang.String filename)
Opens a Stream that the application can write the contents of the file to.
|
GridFSUploadStream |
openUploadStream(java.lang.String filename,
GridFSUploadOptions options)
Opens a Stream that the application can write the contents of the file to.
|
void |
rename(BsonValue id,
java.lang.String newFilename)
Renames the stored file with the specified
id . |
void |
rename(ClientSession clientSession,
BsonValue id,
java.lang.String newFilename)
Renames the stored file with the specified
id . |
void |
rename(ClientSession clientSession,
ObjectId id,
java.lang.String newFilename)
Renames the stored file with the specified
id . |
void |
rename(ObjectId id,
java.lang.String newFilename)
Renames the stored file with the specified
id . |
void |
uploadFromStream(BsonValue id,
java.lang.String filename,
java.io.InputStream source)
Uploads the contents of the given
InputStream to a GridFS bucket. |
void |
uploadFromStream(BsonValue id,
java.lang.String filename,
java.io.InputStream source,
GridFSUploadOptions options)
Uploads the contents of the given
InputStream to a GridFS bucket. |
void |
uploadFromStream(ClientSession clientSession,
BsonValue id,
java.lang.String filename,
java.io.InputStream source)
Uploads the contents of the given
InputStream to a GridFS bucket. |
void |
uploadFromStream(ClientSession clientSession,
BsonValue id,
java.lang.String filename,
java.io.InputStream source,
GridFSUploadOptions options)
Uploads the contents of the given
InputStream to a GridFS bucket. |
ObjectId |
uploadFromStream(ClientSession clientSession,
java.lang.String filename,
java.io.InputStream source)
Uploads the contents of the given
InputStream to a GridFS bucket. |
ObjectId |
uploadFromStream(ClientSession clientSession,
java.lang.String filename,
java.io.InputStream source,
GridFSUploadOptions options)
Uploads the contents of the given
InputStream to a GridFS bucket. |
ObjectId |
uploadFromStream(java.lang.String filename,
java.io.InputStream source)
Uploads the contents of the given
InputStream to a GridFS bucket. |
ObjectId |
uploadFromStream(java.lang.String filename,
java.io.InputStream source,
GridFSUploadOptions options)
Uploads the contents of the given
InputStream to a GridFS bucket. |
GridFSBucket |
withChunkSizeBytes(int chunkSizeBytes)
Create a new GridFSBucket instance with a new chunk size in bytes.
|
GridFSBucket |
withDisableMD5(boolean disableMD5)
Create a new GridFSBucket instance with the set disable MD5 value.
|
GridFSBucket |
withReadConcern(ReadConcern readConcern)
Create a new GridFSBucket 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.
|
java.lang.String getBucketName()
int getChunkSizeBytes()
WriteConcern getWriteConcern()
WriteConcern
ReadPreference getReadPreference()
ReadPreference
ReadConcern getReadConcern()
ReadConcern
boolean getDisableMD5()
GridFSBucket withChunkSizeBytes(int chunkSizeBytes)
chunkSizeBytes
- the new chunk size in bytes.GridFSBucket withReadPreference(ReadPreference readPreference)
readPreference
- the new ReadPreference
for the GridFSBucketGridFSBucket withWriteConcern(WriteConcern writeConcern)
writeConcern
- the new WriteConcern
for the GridFSBucketGridFSBucket withReadConcern(ReadConcern readConcern)
readConcern
- the new ReadConcern
for the GridFSBucketGridFSBucket withDisableMD5(boolean disableMD5)
disableMD5
- true if computing MD5 checksums when uploading files should be disabled.GridFSUploadStream openUploadStream(java.lang.String filename)
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.
filename
- the filename for the streamGridFSUploadStream openUploadStream(java.lang.String filename, GridFSUploadOptions options)
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.
filename
- the filename for the streamoptions
- the GridFSUploadOptionsGridFSUploadStream openUploadStream(BsonValue id, java.lang.String filename)
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.
id
- the custom id value of the filefilename
- the filename for the streamGridFSUploadStream openUploadStream(BsonValue id, java.lang.String filename, GridFSUploadOptions options)
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.
id
- the custom id value of the filefilename
- the filename for the streamoptions
- the GridFSUploadOptionsGridFSUploadStream openUploadStream(ClientSession clientSession, java.lang.String filename)
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.
clientSession
- the client session with which to associate this operationfilename
- the filename for the streamGridFSUploadStream openUploadStream(ClientSession clientSession, java.lang.String filename, GridFSUploadOptions options)
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.
clientSession
- the client session with which to associate this operationfilename
- the filename for the streamoptions
- the GridFSUploadOptionsGridFSUploadStream openUploadStream(ClientSession clientSession, BsonValue id, java.lang.String filename)
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.
clientSession
- the client session with which to associate this operationid
- the custom id value of the filefilename
- the filename for the streamGridFSUploadStream openUploadStream(ClientSession clientSession, ObjectId id, java.lang.String filename)
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.
clientSession
- the client session with which to associate this operationid
- the custom id value of the filefilename
- the filename for the streamGridFSUploadStream openUploadStream(ClientSession clientSession, BsonValue id, java.lang.String filename, GridFSUploadOptions options)
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.
clientSession
- the client session with which to associate this operationid
- the custom id value of the filefilename
- the filename for the streamoptions
- the GridFSUploadOptionsObjectId uploadFromStream(java.lang.String filename, java.io.InputStream source)
InputStream
to a GridFS bucket.
Reads the contents of the user file from the Stream
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.
filename
- the filename for the streamsource
- the Stream providing the file dataObjectId uploadFromStream(java.lang.String filename, java.io.InputStream source, GridFSUploadOptions options)
InputStream
to a GridFS bucket.
Reads the contents of the user file from the Stream
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.
filename
- the filename for the streamsource
- the Stream providing the file dataoptions
- the GridFSUploadOptionsvoid uploadFromStream(BsonValue id, java.lang.String filename, java.io.InputStream source)
InputStream
to a GridFS bucket.
Reads the contents of the user file from the Stream
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.
id
- the custom id value of the filefilename
- the filename for the streamsource
- the Stream providing the file datavoid uploadFromStream(BsonValue id, java.lang.String filename, java.io.InputStream source, GridFSUploadOptions options)
InputStream
to a GridFS bucket.
Reads the contents of the user file from the Stream
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.
id
- the custom id value of the filefilename
- the filename for the streamsource
- the Stream providing the file dataoptions
- the GridFSUploadOptionsObjectId uploadFromStream(ClientSession clientSession, java.lang.String filename, java.io.InputStream source)
InputStream
to a GridFS bucket.
Reads the contents of the user file from the Stream
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.
clientSession
- the client session with which to associate this operationfilename
- the filename for the streamsource
- the Stream providing the file dataObjectId uploadFromStream(ClientSession clientSession, java.lang.String filename, java.io.InputStream source, GridFSUploadOptions options)
InputStream
to a GridFS bucket.
Reads the contents of the user file from the Stream
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.
clientSession
- the client session with which to associate this operationfilename
- the filename for the streamsource
- the Stream providing the file dataoptions
- the GridFSUploadOptionsvoid uploadFromStream(ClientSession clientSession, BsonValue id, java.lang.String filename, java.io.InputStream source)
InputStream
to a GridFS bucket.
Reads the contents of the user file from the Stream
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.
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 datavoid uploadFromStream(ClientSession clientSession, BsonValue id, java.lang.String filename, java.io.InputStream source, GridFSUploadOptions options)
InputStream
to a GridFS bucket.
Reads the contents of the user file from the Stream
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.
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 GridFSUploadOptionsGridFSDownloadStream openDownloadStream(ObjectId id)
id
.id
- the ObjectId of the file to be put into a stream.GridFSDownloadStream openDownloadStream(BsonValue id)
id
.id
- the custom id value of the file, to be put into a stream.GridFSDownloadStream openDownloadStream(java.lang.String filename)
filename
.filename
- the name of the file to be downloadedGridFSDownloadStream openDownloadStream(java.lang.String filename, GridFSDownloadOptions options)
filename
and the revision
in options
.filename
- the name of the file to be downloadedoptions
- the download optionsGridFSDownloadStream openDownloadStream(ClientSession clientSession, ObjectId id)
id
.clientSession
- the client session with which to associate this operationid
- the ObjectId of the file to be put into a stream.GridFSDownloadStream openDownloadStream(ClientSession clientSession, BsonValue id)
id
.clientSession
- the client session with which to associate this operationid
- the custom id value of the file, to be put into a stream.GridFSDownloadStream openDownloadStream(ClientSession clientSession, java.lang.String filename)
filename
.clientSession
- the client session with which to associate this operationfilename
- the name of the file to be downloadedGridFSDownloadStream openDownloadStream(ClientSession clientSession, java.lang.String filename, GridFSDownloadOptions options)
filename
and the revision
in options
.clientSession
- the client session with which to associate this operationfilename
- the name of the file to be downloadedoptions
- the download optionsvoid downloadToStream(ObjectId id, java.io.OutputStream destination)
id
and writes the contents to the destination
Stream.id
- the ObjectId of the file to be written to the destination streamdestination
- the destination streamvoid downloadToStream(BsonValue id, java.io.OutputStream destination)
id
and writes the contents to the destination
Stream.id
- the custom id of the file, to be written to the destination streamdestination
- the destination streamvoid downloadToStream(java.lang.String filename, java.io.OutputStream destination)
filename
and writes the contents to
the destination
Stream.filename
- the name of the file to be downloadeddestination
- the destination streamvoid downloadToStream(java.lang.String filename, java.io.OutputStream destination, GridFSDownloadOptions options)
filename
and by the revision in options
and writes the
contents to the destination
Stream.filename
- the name of the file to be downloadeddestination
- the destination streamoptions
- the download optionsvoid downloadToStream(ClientSession clientSession, ObjectId id, java.io.OutputStream destination)
id
and writes the contents to the destination
Stream.clientSession
- the client session with which to associate this operationid
- the ObjectId of the file to be written to the destination streamdestination
- the destination streamvoid downloadToStream(ClientSession clientSession, BsonValue id, java.io.OutputStream destination)
id
and writes the contents to the destination
Stream.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 streamvoid downloadToStream(ClientSession clientSession, java.lang.String filename, java.io.OutputStream destination)
filename
and writes the contents to
the destination
Stream.clientSession
- the client session with which to associate this operationfilename
- the name of the file to be downloadeddestination
- the destination streamvoid downloadToStream(ClientSession clientSession, java.lang.String filename, java.io.OutputStream destination, GridFSDownloadOptions options)
filename
and by the revision in options
and writes the
contents to the destination
Stream.clientSession
- the client session with which to associate this operationfilename
- the name of the file to be downloadeddestination
- the destination streamoptions
- the download optionsGridFSFindIterable find()
GridFSFindIterable find(Bson 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"));
filter
- the query filterFilters
GridFSFindIterable find(ClientSession clientSession)
clientSession
- the client session with which to associate this operationGridFSFindIterable find(ClientSession clientSession, Bson 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"));
clientSession
- the client session with which to associate this operationfilter
- the query filterFilters
void delete(ObjectId id)
id
, delete this stored file's files collection document and associated chunks from a GridFS bucket.id
- the ObjectId of the file to be deletedvoid delete(BsonValue id)
id
, delete this stored file's files collection document and associated chunks from a GridFS bucket.id
- the id of the file to be deletedvoid delete(ClientSession clientSession, ObjectId id)
id
, delete this stored file's files collection document and associated chunks from a GridFS bucket.clientSession
- the client session with which to associate this operationid
- the ObjectId of the file to be deletedvoid delete(ClientSession clientSession, BsonValue id)
id
, delete this stored file's files collection document and associated chunks from a GridFS bucket.clientSession
- the client session with which to associate this operationid
- the id of the file to be deletedvoid rename(ObjectId id, java.lang.String newFilename)
id
.id
- the id of the file in the files collection to renamenewFilename
- the new filename for the filevoid rename(BsonValue id, java.lang.String newFilename)
id
.id
- the id of the file in the files collection to renamenewFilename
- the new filename for the filevoid rename(ClientSession clientSession, ObjectId id, java.lang.String newFilename)
id
.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 filevoid rename(ClientSession clientSession, BsonValue id, java.lang.String newFilename)
id
.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 filevoid drop()
void drop(ClientSession clientSession)
clientSession
- the client session with which to associate this operation@Deprecated GridFSDownloadStream openDownloadStreamByName(java.lang.String filename)
openDownloadStream(String)
instead.filename
.filename
- the name of the file to be downloaded@Deprecated GridFSDownloadStream openDownloadStreamByName(java.lang.String filename, GridFSDownloadByNameOptions options)
openDownloadStream(String, GridFSDownloadOptions)
instead.filename
and the revision
in options
.filename
- the name of the file to be downloadedoptions
- the download options@Deprecated void downloadToStreamByName(java.lang.String filename, java.io.OutputStream destination)
downloadToStream(String, OutputStream)
instead.filename
and writes the contents to
the destination
Stream.filename
- the name of the file to be downloadeddestination
- the destination stream@Deprecated void downloadToStreamByName(java.lang.String filename, java.io.OutputStream destination, GridFSDownloadByNameOptions options)
downloadToStream(String, OutputStream, GridFSDownloadOptions)
instead.filename
and by the revision in options
and writes the
contents to the destination
Stream.filename
- the name of the file to be downloadeddestination
- the destination streamoptions
- the download optionsCopyright © 2010 - 2020 Adobe. All Rights Reserved