Interface IGridFSBucket<TFileId>
Represents a GridFS system bucket.
public interface IGridFSBucket<TFileId>
Type Parameters
TFileId
The type of the file identifier.
Properties
Database
Gets the database where the GridFS files are stored.
IMongoDatabase Database { get; }
Property Value
- IMongoDatabase
The database.
Options
Gets the options.
ImmutableGridFSBucketOptions Options { get; }
Property Value
- ImmutableGridFSBucketOptions
The options.
Methods
Delete(TFileId, CancellationToken)
Deletes a file from GridFS.
void Delete(TFileId id, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
cancellationToken
CancellationTokenThe cancellation token.
DeleteAsync(TFileId, CancellationToken)
Deletes a file from GridFS.
Task DeleteAsync(TFileId id, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A Task.
DownloadAsBytes(TFileId, GridFSDownloadOptions, CancellationToken)
Downloads a file stored in GridFS and returns it as a byte array.
byte[] DownloadAsBytes(TFileId id, GridFSDownloadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
options
GridFSDownloadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- byte[]
The contents of the file stored in GridFS.
DownloadAsBytesAsync(TFileId, GridFSDownloadOptions, CancellationToken)
Downloads a file stored in GridFS and returns it as a byte array.
Task<byte[]> DownloadAsBytesAsync(TFileId id, GridFSDownloadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
options
GridFSDownloadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<byte[]>
A Task whose result is a byte array containing the contents of the file stored in GridFS.
DownloadAsBytesByName(string, GridFSDownloadByNameOptions, CancellationToken)
Downloads a file stored in GridFS and returns it as a byte array.
byte[] DownloadAsBytesByName(string filename, GridFSDownloadByNameOptions options = null, CancellationToken cancellationToken = default)
Parameters
filename
stringThe filename.
options
GridFSDownloadByNameOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- byte[]
A byte array containing the contents of the file stored in GridFS.
DownloadAsBytesByNameAsync(string, GridFSDownloadByNameOptions, CancellationToken)
Downloads a file stored in GridFS and returns it as a byte array.
Task<byte[]> DownloadAsBytesByNameAsync(string filename, GridFSDownloadByNameOptions options = null, CancellationToken cancellationToken = default)
Parameters
filename
stringThe filename.
options
GridFSDownloadByNameOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<byte[]>
A Task whose result is a byte array containing the contents of the file stored in GridFS.
DownloadToStream(TFileId, Stream, GridFSDownloadOptions, CancellationToken)
Downloads a file stored in GridFS and writes the contents to a stream.
void DownloadToStream(TFileId id, Stream destination, GridFSDownloadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
destination
StreamThe destination.
options
GridFSDownloadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
DownloadToStreamAsync(TFileId, Stream, GridFSDownloadOptions, CancellationToken)
Downloads a file stored in GridFS and writes the contents to a stream.
Task DownloadToStreamAsync(TFileId id, Stream destination, GridFSDownloadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
destination
StreamThe destination.
options
GridFSDownloadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A Task.
DownloadToStreamByName(string, Stream, GridFSDownloadByNameOptions, CancellationToken)
Downloads a file stored in GridFS and writes the contents to a stream.
void DownloadToStreamByName(string filename, Stream destination, GridFSDownloadByNameOptions options = null, CancellationToken cancellationToken = default)
Parameters
filename
stringThe filename.
destination
StreamThe destination.
options
GridFSDownloadByNameOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
DownloadToStreamByNameAsync(string, Stream, GridFSDownloadByNameOptions, CancellationToken)
Downloads a file stored in GridFS and writes the contents to a stream.
Task DownloadToStreamByNameAsync(string filename, Stream destination, GridFSDownloadByNameOptions options = null, CancellationToken cancellationToken = default)
Parameters
filename
stringThe filename.
destination
StreamThe destination.
options
GridFSDownloadByNameOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A Task.
Drop(CancellationToken)
Drops the files and chunks collections associated with this GridFS bucket.
void Drop(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
DropAsync(CancellationToken)
Drops the files and chunks collections associated with this GridFS bucket.
Task DropAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A Task.
Find(FilterDefinition<GridFSFileInfo<TFileId>>, GridFSFindOptions<TFileId>, CancellationToken)
Finds matching entries from the files collection.
IAsyncCursor<GridFSFileInfo<TFileId>> Find(FilterDefinition<GridFSFileInfo<TFileId>> filter, GridFSFindOptions<TFileId> options = null, CancellationToken cancellationToken = default)
Parameters
filter
FilterDefinition<GridFSFileInfo<TFileId>>The filter.
options
GridFSFindOptions<TFileId>The options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- IAsyncCursor<GridFSFileInfo<TFileId>>
A cursor of files collection documents.
FindAsync(FilterDefinition<GridFSFileInfo<TFileId>>, GridFSFindOptions<TFileId>, CancellationToken)
Finds matching entries from the files collection.
Task<IAsyncCursor<GridFSFileInfo<TFileId>>> FindAsync(FilterDefinition<GridFSFileInfo<TFileId>> filter, GridFSFindOptions<TFileId> options = null, CancellationToken cancellationToken = default)
Parameters
filter
FilterDefinition<GridFSFileInfo<TFileId>>The filter.
options
GridFSFindOptions<TFileId>The options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<GridFSFileInfo<TFileId>>>
A Task whose result is a cursor of files collection documents.
OpenDownloadStream(TFileId, GridFSDownloadOptions, CancellationToken)
Opens a Stream that can be used by the application to read data from a GridFS file.
GridFSDownloadStream<TFileId> OpenDownloadStream(TFileId id, GridFSDownloadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
options
GridFSDownloadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- GridFSDownloadStream<TFileId>
A Stream.
OpenDownloadStreamAsync(TFileId, GridFSDownloadOptions, CancellationToken)
Opens a Stream that can be used by the application to read data from a GridFS file.
Task<GridFSDownloadStream<TFileId>> OpenDownloadStreamAsync(TFileId id, GridFSDownloadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
options
GridFSDownloadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<GridFSDownloadStream<TFileId>>
A Task whose result is a Stream.
OpenDownloadStreamByName(string, GridFSDownloadByNameOptions, CancellationToken)
Opens a Stream that can be used by the application to read data from a GridFS file.
GridFSDownloadStream<TFileId> OpenDownloadStreamByName(string filename, GridFSDownloadByNameOptions options = null, CancellationToken cancellationToken = default)
Parameters
filename
stringThe filename.
options
GridFSDownloadByNameOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- GridFSDownloadStream<TFileId>
A Stream.
OpenDownloadStreamByNameAsync(string, GridFSDownloadByNameOptions, CancellationToken)
Opens a Stream that can be used by the application to read data from a GridFS file.
Task<GridFSDownloadStream<TFileId>> OpenDownloadStreamByNameAsync(string filename, GridFSDownloadByNameOptions options = null, CancellationToken cancellationToken = default)
Parameters
filename
stringThe filename.
options
GridFSDownloadByNameOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<GridFSDownloadStream<TFileId>>
A Task whose result is a Stream.
OpenUploadStream(TFileId, string, GridFSUploadOptions, CancellationToken)
Opens a Stream that can be used by the application to write data to a GridFS file.
GridFSUploadStream<TFileId> OpenUploadStream(TFileId id, string filename, GridFSUploadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
filename
stringThe filename.
options
GridFSUploadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- GridFSUploadStream<TFileId>
A Stream.
OpenUploadStreamAsync(TFileId, string, GridFSUploadOptions, CancellationToken)
Opens a Stream that can be used by the application to write data to a GridFS file.
Task<GridFSUploadStream<TFileId>> OpenUploadStreamAsync(TFileId id, string filename, GridFSUploadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
filename
stringThe filename.
options
GridFSUploadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<GridFSUploadStream<TFileId>>
A Task whose result is a Stream.
Rename(TFileId, string, CancellationToken)
Renames a GridFS file.
void Rename(TFileId id, string newFilename, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
newFilename
stringThe new filename.
cancellationToken
CancellationTokenThe cancellation token.
RenameAsync(TFileId, string, CancellationToken)
Renames a GridFS file.
Task RenameAsync(TFileId id, string newFilename, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
newFilename
stringThe new filename.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A Task.
UploadFromBytes(TFileId, string, byte[], GridFSUploadOptions, CancellationToken)
Uploads a file (or a new revision of a file) to GridFS.
void UploadFromBytes(TFileId id, string filename, byte[] source, GridFSUploadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
filename
stringThe filename.
source
byte[]The source.
options
GridFSUploadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
UploadFromBytesAsync(TFileId, string, byte[], GridFSUploadOptions, CancellationToken)
Uploads a file (or a new revision of a file) to GridFS.
Task UploadFromBytesAsync(TFileId id, string filename, byte[] source, GridFSUploadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
filename
stringThe filename.
source
byte[]The source.
options
GridFSUploadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A Task.
UploadFromStream(TFileId, string, Stream, GridFSUploadOptions, CancellationToken)
Uploads a file (or a new revision of a file) to GridFS.
void UploadFromStream(TFileId id, string filename, Stream source, GridFSUploadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
filename
stringThe filename.
source
StreamThe source.
options
GridFSUploadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
UploadFromStreamAsync(TFileId, string, Stream, GridFSUploadOptions, CancellationToken)
Uploads a file (or a new revision of a file) to GridFS.
Task UploadFromStreamAsync(TFileId id, string filename, Stream source, GridFSUploadOptions options = null, CancellationToken cancellationToken = default)
Parameters
id
TFileIdThe file id.
filename
stringThe filename.
source
StreamThe source.
options
GridFSUploadOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A Task.