请看下图,来自http://mongoexplorer.com/ http://mongoexplorer.com/:
我一直在尝试通过 GridFS 进行工作,参考https://github.com/jamescarr/nodejs-mongodb-streaming https://github.com/jamescarr/nodejs-mongodb-streaming。我上传的文件很好地返回,并且通过以下 get 函数返回的流看起来正确。
var gridfs = (function () {
function gridfs() { }
gridfs.get = function (id, fn) {
var db, store;
db = mongoose.connection.db;
id = new ObjectID(id);
store = new GridStore(db, id, "r", {
root: "fs"
});
return store.open(function (err, store) {
if (err) {
return fn(err);
}
return fn(null, store);
});
};
return gridfs;
})();
Using http://mongoexplorer.com/ http://mongoexplorer.com/我将文件上传到 GridFS 进行测试,但当我使用上面的节点代码检索它们时,它们似乎已损坏。
就在那时我注意到了文件名/文件名的事情。看着这里/node_modules/mongodb/lib/mongodb/gridfs/gridstore.js我看到对文件名的引用带有小写“N”,但在我的 GridFS 中,它的文件名带有大写“N”。
好的,为了好玩,我在 GridFS 中将其更改为小写,但在检索使用 上传的文件时,流中仍然出现一些损坏(上面的节点代码)http://mongoexplorer.com/ http://mongoexplorer.com/。
点击另存为... in http://mongoexplorer.com/ http://mongoexplorer.com/,但是完美地恢复了我的罚款。
回到我的问题,(因为我的测试似乎没有证明任何事情,)我想知道它是什么:带有小写“N”的文件名,还是带有大写“N”的文件名?