如何覆盖 MongoDB Gridfs 中的文件?
我正在使用以下代码写入 MongoDB gridfs:
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);
当我查看 Gridfs 时,我可以看到文件似乎正在被添加,因此我最终得到了许多具有相同名称的文件。当我读取 gridfs 时,它总是返回最新的文件,因此一切正常,但似乎效率很低。
如何执行 MongoDB gridfs 写入来覆盖任何现有的同名文件?
I am writing to the MongoDB gridfs 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 into Gridfs I can see that files seem to be being added, so I'm ending up with lots of files with the same name. When I read the gridfs it always returns the latest file, so it all works ok, but it seems rather inefficient.
How do I perform a MongoDB gridfs write that overwrites any exiting file with the same name?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
mongodb 不支持这个。
我认为你可以先删除同名文件。就像:
mongodb does not support this.
I think you can delete file with the same name first .just like: