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
databaseMongoDatabaseThe 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
databaseMongoDatabaseThe database containing the GridFS collections.
settingsMongoGridFSSettingsThe GridFS settings.
MongoGridFS(MongoServer, string, MongoGridFSSettings)
Initializes a new instance of the MongoGridFS class.
public MongoGridFS(MongoServer server, string databaseName, MongoGridFSSettings settings)
Parameters
serverMongoServerThe server.
databaseNamestringThe name of the database.
settingsMongoGridFSSettingsThe 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
remoteFileNamestringThe 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
sourceFileNamestringThe source file name.
destFileNamestringThe destination file name.
createOptionsMongoGridFSCreateOptionsThe 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
remoteFileNamestringThe remote file name.
Returns
- MongoGridFSStream
A stream.
Create(string, MongoGridFSCreateOptions)
Creates or overwrites a GridFS file.
public MongoGridFSStream Create(string remoteFileName, MongoGridFSCreateOptions createOptions)
Parameters
remoteFileNamestringThe remote file name.
createOptionsMongoGridFSCreateOptionsThe 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
remoteFileNamestringThe 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
remoteFileNamestringThe remote file name.
createOptionsMongoGridFSCreateOptionsThe create options.
Returns
- StreamWriter
A stream writer.
Delete(IMongoQuery)
Deletes GridFS files.
public void Delete(IMongoQuery query)
Parameters
queryIMongoQueryA query that specifies the GridFS files to delete.
Delete(string)
Deletes all versions of a GridFS file.
public void Delete(string remoteFileName)
Parameters
remoteFileNamestringThe remote file name.
DeleteById(BsonValue)
Deletes a GridFS file.
public void DeleteById(BsonValue id)
Parameters
idBsonValueThe GridFS file Id.
Download(Stream, MongoGridFSFileInfo)
Downloads a GridFS file.
public void Download(Stream stream, MongoGridFSFileInfo fileInfo)
Parameters
streamStreamThe destination stream.
fileInfoMongoGridFSFileInfoThe GridFS file.
Download(Stream, IMongoQuery)
Downloads the most recent version of a GridFS file.
public void Download(Stream stream, IMongoQuery query)
Parameters
streamStreamThe destination stream.
queryIMongoQueryThe GridFS file.
Download(Stream, IMongoQuery, int)
Downloads a specific version of a GridFS file.
public void Download(Stream stream, IMongoQuery query, int version)
Parameters
streamStreamThe destination stream.
queryIMongoQueryThe GridFS file.
versionintThe 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
streamStreamThe destination stream.
remoteFileNamestringThe remote file name.
versionintThe version to download.
Download(string)
Downloads the most recent version of a GridFS file.
public void Download(string fileName)
Parameters
fileNamestringThe file name (same local and remote names).
Download(string, MongoGridFSFileInfo)
Downloads a GridFS file.
public void Download(string localFileName, MongoGridFSFileInfo fileInfo)
Parameters
localFileNamestringThe local file name.
fileInfoMongoGridFSFileInfoThe GridFS file.
Download(string, IMongoQuery)
Downloads the most recent version of a GridFS file.
public void Download(string localFileName, IMongoQuery query)
Parameters
localFileNamestringThe local file name.
queryIMongoQueryThe GridFS file.
Download(string, IMongoQuery, int)
Downloads a specific version of a GridFS file.
public void Download(string localFileName, IMongoQuery query, int version)
Parameters
localFileNamestringThe local file name.
queryIMongoQueryThe GridFS file.
versionintThe 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
localFileNamestringThe local file name.
remoteFileNamestringThe remote file name.
versionintThe 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
maxFilesintOnly 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
queryIMongoQueryThe GridFS file.
Returns
- bool
True if the GridFS file exists.
Exists(string)
Tests whether a GridFS file exists.
public bool Exists(string remoteFileName)
Parameters
remoteFileNamestringThe GridFS file.
Returns
- bool
True if the GridFS file exists.
ExistsById(BsonValue)
Tests whether a GridFS file exists.
public bool ExistsById(BsonValue id)
Parameters
idBsonValueThe GridFS file.
Returns
- bool
True if the GridFS file exists.
Find(IMongoQuery)
Finds matching GridFS files.
public MongoCursor<MongoGridFSFileInfo> Find(IMongoQuery query)
Parameters
queryIMongoQueryA query.
Returns
- MongoCursor<MongoGridFSFileInfo>
The matching GridFS files.
Find(string)
Finds matching GridFS files.
public MongoCursor<MongoGridFSFileInfo> Find(string remoteFileName)
Parameters
remoteFileNamestringThe 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
queryIMongoQueryThe 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
queryIMongoQueryThe GridFS file.
versionintThe 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
remoteFileNamestringThe 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
idBsonValueThe 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
remoteFileNamestringThe remote file name.
modeFileModeThe mode.
accessFileAccessThe 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
remoteFileNamestringThe remote file name.
modeFileModeThe mode.
accessFileAccessThe access.
createOptionsMongoGridFSCreateOptionsThe create options.
Returns
- MongoGridFSStream
A stream.
OpenRead(string)
Opens an existing GridFS file for reading.
public MongoGridFSStream OpenRead(string remoteFileName)
Parameters
remoteFileNamestringThe 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
remoteFileNamestringThe remote file name.
Returns
- StreamReader
A stream reader.
OpenWrite(string)
Opens an existing GridFS file for writing.
public MongoGridFSStream OpenWrite(string remoteFileName)
Parameters
remoteFileNamestringThe 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
remoteFileNamestringThe remote file name.
createOptionsMongoGridFSCreateOptionsThe 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
fileInfoMongoGridFSFileInfoThe GridFS file.
aliasesstring[]The aliases.
SetContentType(MongoGridFSFileInfo, string)
Sets the content type for an existing GridFS file.
public void SetContentType(MongoGridFSFileInfo fileInfo, string contentType)
Parameters
fileInfoMongoGridFSFileInfoThe GridFS file.
contentTypestringThe content type.
SetMetadata(MongoGridFSFileInfo, BsonValue)
Sets the metadata for an existing GridFS file.
public void SetMetadata(MongoGridFSFileInfo fileInfo, BsonValue metadata)
Parameters
fileInfoMongoGridFSFileInfoThe GridFS file.
metadataBsonValueThe 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
streamStreamThe source stream.
remoteFileNamestringThe remote file name.
createOptionsMongoGridFSCreateOptionsThe create options.
Returns
- MongoGridFSFileInfo
The file info of the new GridFS file.
Upload(string)
Uploads a GridFS file.
public MongoGridFSFileInfo Upload(string fileName)
Parameters
fileNamestringThe 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.