I write in gridfs MongoDB using the following code:
MongoDB.Driver.GridFS.MongoGridFSCreateOptions createOptions = new MongoDB.Driver.GridFS.MongoGridFSCreateOptions();
createOptions.ContentType = Helper.GetFileExtensionFromFilename(clientToSave.LogoFilename);
var gridFsInfo = adminDB.GridFS.Upload(clientToSave.LogoStream, clientToSave.DatabaseName, createOptions);
When I look through Gridfs, I see that the files seem to be being added, so I get a lot of files with the same name. When I read gridfs, it always returns the last file, so everything works fine, but it seems pretty inefficient.
How to write to gridfs from MongoDB that overwrites any output file with the same name?
source
share