1
當我嘗試將大文件(1.8GB)上傳到GridFS時,Mongodb似乎會隨意返回。較小的文件工作得很好。MongoDB(Node.js本地驅動程序)大型網格上傳失敗
我正在使用node.js本地驅動程序。代碼(與略去了一些東西)如下:
var objectId = new ObjectID(),
gridStore = new GridStore(db, objectId, filename /*declared elsewhere*/, "w", { "content_type": contentType /* declared elsewhere */ }),
obj = {};
gridStore.open(function (err, gs) {
console.log("gridStore open");
gs.writeFile(tempFile, function (err, doc) {
if (err) {
throw err;
}
console.log("file written");
obj.fileId = doc._id;
// double check the md5 of the uploaded file against what was uploaded
// (md5 variable declared elsewhere)
if (doc.md5 !== md5) {
console.log(doc);
console.log(doc.md5);
console.log(md5);
//delete bad file
GridStore.unlink(db, doc.filename, function (err, gridStore) {
if (err) {
throw err;
}
});
} else {
// do the desired stuff
}
});
});
的「文檔」對象似乎總是有不同的長度(和明顯不同的MD5)返回。