0
下面的代碼示例:GridFS.Upload()不上載流內容
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#驅動。