使用C#驱动程序将文件上载到mongoDB,GridFS生成断言

时间:2011-11-23 10:44:16

标签: c# mongodb md5 gridfs

首先,设置:

  • 服务器:Ubuntu 10.04服务器

    mongod --version

    db version v1.2.2,pdfile version 4.5

    11月23日星期三11:35:42 git版本:nogitversion

  • 客户端:Windows 7 64位,VS2010应用,使用官方C#驱动程序v1.3。

我正在尝试使用GridFS在pongoDB中存储png图像。我的代码如下所示:

var GridFSInfo = DB.GridFS.Upload(TextureFileName, TextureFileName);

运行此代码我收到以下异常

An unhandled exception of type 'MongoDB.Driver.GridFS.MongoGridFSException' occurred in MongoDB.Driver.dll 

Additional information: Upload client and server MD5 hashes are not equal.

我试图找到有关此错误的信息,但我似乎是唯一一个遇到此问题的人:(

服务器日志没有给出任何错误,我得到的是:

Wed Nov 23 11:42:23 connection accepted from 141.3.89.168:16861 #159
Wed Nov 23 11:42:25 building new index on { _id: ObjId(000000000000000000000000) } for ObjectDBTest.fs.files...
Wed Nov 23 11:42:25 Buildindex ObjectDBTest.fs.files idxNo:0 { name: "_id_", ns: "ObjectDBTest.fs.files", key: { _id: ObjId(000000000000000000000000) } }
Wed Nov 23 11:42:25 done for 0 records 0secs
Wed Nov 23 11:42:25 info: creating collection ObjectDBTest.fs.files on add index
Wed Nov 23 11:42:25 building new index on { filename: 1, uploadDate: 1 } for ObjectDBTest.fs.files...
Wed Nov 23 11:42:25 Buildindex ObjectDBTest.fs.files idxNo:1 { _id: ObjId(4ecccd0382522c02f8e58d75), name: "filename_1_uploadDate_1", ns:    "ObjectDBTest.fs.files", key: { filename: 1, uploadDate: 1 } }
Wed Nov 23 11:42:25 done for 0 records 0secs
Wed Nov 23 11:42:25 building new index on { _id: ObjId(000000000000000000000000) } for ObjectDBTest.fs.chunks...
Wed Nov 23 11:42:25 Buildindex ObjectDBTest.fs.chunks idxNo:0 { name: "_id_", ns: "ObjectDBTest.fs.chunks", key: { _id: ObjId(000000000000000000000000) } }
Wed Nov 23 11:42:25 done for 0 records 0secs
Wed Nov 23 11:42:25 info: creating collection ObjectDBTest.fs.chunks on add index
Wed Nov 23 11:42:25 building new index on { files_id: 1, n: 1 } for ObjectDBTest.fs.chunks...
Wed Nov 23 11:42:25 Buildindex ObjectDBTest.fs.chunks idxNo:1 { _id: ObjId(4ecccd0382522c02f8e58d76), name: "files_id_1_n_1", ns: "ObjectDBTest.fs.chunks", key: { files_id: 1, n: 1 }, unique: true }
Wed Nov 23 11:42:25 done for 0 records 0secs
Wed Nov 23 11:42:29 end connection 141.3.89.168:16861

在我看来,文件传输已启动,但随后出现问题。我三重检查文件是否存在。我使用mongofiles命令行实用程序来查看GridFS是否正常工作,一切都很好,上传文件没问题。如果我不进行GridFS上传并且仅使用标准的BSON文档操作,我的应用程序也可以正常工作。我可以插入,搜索,删除罚款,因此与服务器的连接可以正常工作。

我现在不知道这可能是什么来源。我会感激任何提示。

1 个答案:

答案 0 :(得分:0)

这很容易重现吗?它与特定文件有关吗?如果您有任何提示可以重现这一点,请告诉我。

你真的使用服务器的v1.2.2吗?当前版本是2.0.1。