Mongodb seems to be arbitrarily returning early when I try to upload a large file (1.8GB) to GridFS. Smaller files work just fine.
I'm using the node.js native driver. The code (with a few things omitted for brevity) is as follows:
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
}
});
});
The "doc" object always seems to return with a different length (and obviously a different md5).
The issue was apparently with earlier versions of Node's stream implementation. 10Gen's Node driver team wrote the new versions of the driver to use the newer Node stream implementation. So, an upgrade of Node and the native client driver fixed this issue.