以下示例代码:
using (var ms = new MemoryStream())
{
var artifactContent = Encoding.UTF8.GetBytes("content of some file/upload/etc as string");
ms.Write(artifactContent, 0, artifactContent.Length);
// ms.Lenght > 0
var gridFsCreateOptions = new MongoGridFSCreateOptions {ContentType = "text/plain"};
var gridFsFileInfo = mongoGridFsDatabase.GridFS.Upload(ms, "Test.txt", gridFsCreateOptions);
// stream is not uploaded and gridFsFileInfo.Lenght == 0
}
fs.files
集合已满,但集合fs.chunks
为空。
我的代码有什么问题?我在 Win8 上使用 MongoDB 2.4.7 和来自 NuGet 的官方 C# 驱动程序。