Class MongoGridFS
Represents a GridFS file system.
public class MongoGridFS
- Inheritance
-
MongoGridFS
- Inherited Members
- Extension Methods
Constructors
MongoGridFS(MongoDatabase)
Initializes a new instance of the MongoGridFS class.
[Obsolete("Use a different constructor instead.")]
public MongoGridFS(MongoDatabase database)
Parameters
database
MongoDatabaseThe database containing the GridFS collections.
MongoGridFS(MongoDatabase, MongoGridFSSettings)
Initializes a new instance of the MongoGridFS class.
[Obsolete("Use a different constructor instead.")]
public MongoGridFS(MongoDatabase database, MongoGridFSSettings settings)
Parameters
database
MongoDatabaseThe database containing the GridFS collections.
settings
MongoGridFSSettingsThe GridFS settings.
MongoGridFS(MongoServer, string, MongoGridFSSettings)
Initializes a new instance of the MongoGridFS class.
public MongoGridFS(MongoServer server, string databaseName, MongoGridFSSettings settings)
Parameters
server
MongoServerThe server.
databaseName
stringThe name of the database.
settings
MongoGridFSSettingsThe settings.
Properties
Chunks
Gets the chunks collection.
public MongoCollection<BsonDocument> Chunks { get; }
Property Value
Database
Gets the database containing the GridFS collections.
public MongoDatabase Database { get; }
Property Value
DatabaseName
Gets the database containing the GridFS collections.
public string DatabaseName { get; }
Property Value
Files
Gets the files collection.
public MongoCollection<BsonDocument> Files { get; }
Property Value
Server
Gets the server containing the GridFS collections.
public MongoServer Server { get; }
Property Value
Settings
Gets the GridFS settings.
public MongoGridFSSettings Settings { get; }
Property Value
Methods
AppendText(string)
Appends UTF-8 encoded text to an existing GridFS file.
public StreamWriter AppendText(string remoteFileName)
Parameters
remoteFileName
stringThe remote file name.
Returns
- StreamWriter
A StreamWriter.
CopyTo(string, string)
Copies a GridFS file.
public MongoGridFSFileInfo CopyTo(string sourceFileName, string destFileName)
Parameters
Returns
- MongoGridFSFileInfo
The file info of the new GridFS file.
CopyTo(string, string, MongoGridFSCreateOptions)
Copies a GridFS file.
public MongoGridFSFileInfo CopyTo(string sourceFileName, string destFileName, MongoGridFSCreateOptions createOptions)
Parameters
sourceFileName
stringThe source file name.
destFileName
stringThe destination file name.
createOptions
MongoGridFSCreateOptionsThe create options.
Returns
- MongoGridFSFileInfo
The file info of the new GridFS file.
Create(string)
Creates or overwrites a GridFS file.
public MongoGridFSStream Create(string remoteFileName)
Parameters
remoteFileName
stringThe remote file name.
Returns
- MongoGridFSStream
A stream.
Create(string, MongoGridFSCreateOptions)
Creates or overwrites a GridFS file.
public MongoGridFSStream Create(string remoteFileName, MongoGridFSCreateOptions createOptions)
Parameters
remoteFileName
stringThe remote file name.
createOptions
MongoGridFSCreateOptionsThe create options.
Returns
- MongoGridFSStream
A stream.
CreateText(string)
Creates or opens a GridFS file for writing UTF-8 encoded text.
public StreamWriter CreateText(string remoteFileName)
Parameters
remoteFileName
stringThe remote file name.
Returns
- StreamWriter
A stream writer.
CreateText(string, MongoGridFSCreateOptions)
Creates or opens a GridFS file for writing UTF-8 encoded text.
public StreamWriter CreateText(string remoteFileName, MongoGridFSCreateOptions createOptions)
Parameters
remoteFileName
stringThe remote file name.
createOptions
MongoGridFSCreateOptionsThe create options.
Returns
- StreamWriter
A stream writer.
Delete(IMongoQuery)
Deletes GridFS files.
public void Delete(IMongoQuery query)
Parameters
query
IMongoQueryA query that specifies the GridFS files to delete.
Delete(string)
Deletes all versions of a GridFS file.
public void Delete(string remoteFileName)
Parameters
remoteFileName
stringThe remote file name.
DeleteById(BsonValue)
Deletes a GridFS file.
public void DeleteById(BsonValue id)
Parameters
id
BsonValueThe GridFS file Id.
Download(Stream, MongoGridFSFileInfo)
Downloads a GridFS file.
public void Download(Stream stream, MongoGridFSFileInfo fileInfo)
Parameters
stream
StreamThe destination stream.
fileInfo
MongoGridFSFileInfoThe GridFS file.
Download(Stream, IMongoQuery)
Downloads the most recent version of a GridFS file.
public void Download(Stream stream, IMongoQuery query)
Parameters
stream
StreamThe destination stream.
query
IMongoQueryThe GridFS file.
Download(Stream, IMongoQuery, int)
Downloads a specific version of a GridFS file.
public void Download(Stream stream, IMongoQuery query, int version)
Parameters
stream
StreamThe destination stream.
query
IMongoQueryThe GridFS file.
version
intThe version to download.
Download(Stream, string)
Downloads the most recent version of a GridFS file.
public void Download(Stream stream, string remoteFileName)
Parameters
Download(Stream, string, int)
Downloads a specific version of a GridFS file.
public void Download(Stream stream, string remoteFileName, int version)
Parameters
stream
StreamThe destination stream.
remoteFileName
stringThe remote file name.
version
intThe version to download.
Download(string)
Downloads the most recent version of a GridFS file.
public void Download(string fileName)
Parameters
fileName
stringThe file name (same local and remote names).
Download(string, MongoGridFSFileInfo)
Downloads a GridFS file.
public void Download(string localFileName, MongoGridFSFileInfo fileInfo)
Parameters
localFileName
stringThe local file name.
fileInfo
MongoGridFSFileInfoThe GridFS file.
Download(string, IMongoQuery)
Downloads the most recent version of a GridFS file.
public void Download(string localFileName, IMongoQuery query)
Parameters
localFileName
stringThe local file name.
query
IMongoQueryThe GridFS file.
Download(string, IMongoQuery, int)
Downloads a specific version of a GridFS file.
public void Download(string localFileName, IMongoQuery query, int version)
Parameters
localFileName
stringThe local file name.
query
IMongoQueryThe GridFS file.
version
intThe version to download.
Download(string, int)
Downloads a specific version of a GridFS file.
public void Download(string fileName, int version)
Parameters
Download(string, string)
Downloads the most recent version of a GridFS file.
public void Download(string localFileName, string remoteFileName)
Parameters
Download(string, string, int)
Downloads a specific version of a GridFS file.
public void Download(string localFileName, string remoteFileName, int version)
Parameters
localFileName
stringThe local file name.
remoteFileName
stringThe remote file name.
version
intThe version to download.
EnsureIndexes()
Ensures that the proper indexes for GridFS exist (only creates the new indexes if there are fewer than 1000 GridFS files).
public void EnsureIndexes()
EnsureIndexes(int)
Ensures that the proper indexes for GridFS exist.
public void EnsureIndexes(int maxFiles)
Parameters
maxFiles
intOnly create new indexes if there are fewer than this number of GridFS files).
Exists(IMongoQuery)
Tests whether a GridFS file exists.
public bool Exists(IMongoQuery query)
Parameters
query
IMongoQueryThe GridFS file.
Returns
- bool
True if the GridFS file exists.
Exists(string)
Tests whether a GridFS file exists.
public bool Exists(string remoteFileName)
Parameters
remoteFileName
stringThe GridFS file.
Returns
- bool
True if the GridFS file exists.
ExistsById(BsonValue)
Tests whether a GridFS file exists.
public bool ExistsById(BsonValue id)
Parameters
id
BsonValueThe GridFS file.
Returns
- bool
True if the GridFS file exists.
Find(IMongoQuery)
Finds matching GridFS files.
public MongoCursor<MongoGridFSFileInfo> Find(IMongoQuery query)
Parameters
query
IMongoQueryA query.
Returns
- MongoCursor<MongoGridFSFileInfo>
The matching GridFS files.
Find(string)
Finds matching GridFS files.
public MongoCursor<MongoGridFSFileInfo> Find(string remoteFileName)
Parameters
remoteFileName
stringThe remote file name.
Returns
- MongoCursor<MongoGridFSFileInfo>
The matching GridFS files.
FindAll()
Finds all GridFS files.
public MongoCursor<MongoGridFSFileInfo> FindAll()
Returns
- MongoCursor<MongoGridFSFileInfo>
The matching GridFS files.
FindOne(IMongoQuery)
Finds the most recent version of a GridFS file.
public MongoGridFSFileInfo FindOne(IMongoQuery query)
Parameters
query
IMongoQueryThe GridFS file.
Returns
- MongoGridFSFileInfo
The matching GridFS file.
FindOne(IMongoQuery, int)
Finds a specific version of a GridFS file.
public MongoGridFSFileInfo FindOne(IMongoQuery query, int version)
Parameters
query
IMongoQueryThe GridFS file.
version
intThe version to find (1 is oldest, -1 is newest, 0 is no sort).
Returns
- MongoGridFSFileInfo
The matching GridFS file.
FindOne(string)
Finds the most recent version of a GridFS file.
public MongoGridFSFileInfo FindOne(string remoteFileName)
Parameters
remoteFileName
stringThe remote file name.
Returns
- MongoGridFSFileInfo
The matching GridFS file.
FindOne(string, int)
Finds a specific version of a GridFS file.
public MongoGridFSFileInfo FindOne(string remoteFileName, int version)
Parameters
Returns
- MongoGridFSFileInfo
The matching GridFS file.
FindOneById(BsonValue)
Finds a GridFS file.
public MongoGridFSFileInfo FindOneById(BsonValue id)
Parameters
id
BsonValueThe GridFS file Id.
Returns
- MongoGridFSFileInfo
The GridFS file.
MoveTo(string, string)
Moves the most recent version of a GridFS file.
public void MoveTo(string sourceFileName, string destFileName)
Parameters
Open(string, FileMode)
Opens a GridFS file with the specified mode.
public MongoGridFSStream Open(string remoteFileName, FileMode mode)
Parameters
Returns
- MongoGridFSStream
A stream.
Open(string, FileMode, FileAccess)
Opens a GridFS file with the specified mode and access.
public MongoGridFSStream Open(string remoteFileName, FileMode mode, FileAccess access)
Parameters
remoteFileName
stringThe remote file name.
mode
FileModeThe mode.
access
FileAccessThe access.
Returns
- MongoGridFSStream
A stream.
Open(string, FileMode, FileAccess, MongoGridFSCreateOptions)
Opens a GridFS file with the specified mode, access and create options.
public MongoGridFSStream Open(string remoteFileName, FileMode mode, FileAccess access, MongoGridFSCreateOptions createOptions)
Parameters
remoteFileName
stringThe remote file name.
mode
FileModeThe mode.
access
FileAccessThe access.
createOptions
MongoGridFSCreateOptionsThe create options.
Returns
- MongoGridFSStream
A stream.
OpenRead(string)
Opens an existing GridFS file for reading.
public MongoGridFSStream OpenRead(string remoteFileName)
Parameters
remoteFileName
stringThe remote file name.
Returns
- MongoGridFSStream
A stream.
OpenText(string)
Opens an existing UTF-8 encoded text GridFS file for reading.
public StreamReader OpenText(string remoteFileName)
Parameters
remoteFileName
stringThe remote file name.
Returns
- StreamReader
A stream reader.
OpenWrite(string)
Opens an existing GridFS file for writing.
public MongoGridFSStream OpenWrite(string remoteFileName)
Parameters
remoteFileName
stringThe remote file name.
Returns
- MongoGridFSStream
A stream.
OpenWrite(string, MongoGridFSCreateOptions)
Opens an existing GridFS file for writing.
public MongoGridFSStream OpenWrite(string remoteFileName, MongoGridFSCreateOptions createOptions)
Parameters
remoteFileName
stringThe remote file name.
createOptions
MongoGridFSCreateOptionsThe create options.
Returns
- MongoGridFSStream
A stream.
SetAliases(MongoGridFSFileInfo, string[])
Sets the aliases for an existing GridFS file.
public void SetAliases(MongoGridFSFileInfo fileInfo, string[] aliases)
Parameters
fileInfo
MongoGridFSFileInfoThe GridFS file.
aliases
string[]The aliases.
SetContentType(MongoGridFSFileInfo, string)
Sets the content type for an existing GridFS file.
public void SetContentType(MongoGridFSFileInfo fileInfo, string contentType)
Parameters
fileInfo
MongoGridFSFileInfoThe GridFS file.
contentType
stringThe content type.
SetMetadata(MongoGridFSFileInfo, BsonValue)
Sets the metadata for an existing GridFS file.
public void SetMetadata(MongoGridFSFileInfo fileInfo, BsonValue metadata)
Parameters
fileInfo
MongoGridFSFileInfoThe GridFS file.
metadata
BsonValueThe metadata.
Upload(Stream, string)
Uploads a GridFS file.
public MongoGridFSFileInfo Upload(Stream stream, string remoteFileName)
Parameters
Returns
- MongoGridFSFileInfo
The file info of the new GridFS file.
Upload(Stream, string, MongoGridFSCreateOptions)
Uploads a GridFS file.
public MongoGridFSFileInfo Upload(Stream stream, string remoteFileName, MongoGridFSCreateOptions createOptions)
Parameters
stream
StreamThe source stream.
remoteFileName
stringThe remote file name.
createOptions
MongoGridFSCreateOptionsThe create options.
Returns
- MongoGridFSFileInfo
The file info of the new GridFS file.
Upload(string)
Uploads a GridFS file.
public MongoGridFSFileInfo Upload(string fileName)
Parameters
fileName
stringThe file name (same local and remote names).
Returns
- MongoGridFSFileInfo
The file info of the new GridFS file.
Upload(string, string)
Uploads a GridFS file.
public MongoGridFSFileInfo Upload(string localFileName, string remoteFileName)
Parameters
Returns
- MongoGridFSFileInfo
The file info of the new GridFS file.