我开发了一个新网站,我想使用GridFS作为所有用户上传的存储,因为与普通的文件系统存储相比,它提供了很多优势.
由nginx提供服务的GridFS基准测试表明,它不如nginx提供的普通文件系统快.
有人在那里,谁已经在生产环境中使用GridFS,或者将它用于新项目?
如何限制文件夹,所以只有登录我的Meteor应用程序的人才能下载文件?
我研究了多种方法,但主要问题是我无法访问(我得到null.):
Meteor.user() or this.userId()
Run Code Online (Sandbox Code Playgroud)
我试过了:
__meteor_bootstrap__.app
.use(connect.query())
.use(function(req, res, next) {
Fiber(function () {
// USER HERE?
}).run();
});
Run Code Online (Sandbox Code Playgroud)
要么
__meteor_bootstrap__.app.stack.unshift({
route: "/protected/secret_document.doc", // only users can download this
handle: function(req, res) { Fiber(function() {
// CHECK USER HERE ?
// IF NOT LOGGED IN:
res.writeHead(403, {'Content-Type': 'text/html'});
var content = '<html><body>403 Forbidden</body></html>';
res.end(content, 'utf-8');
}).run() }
});
Run Code Online (Sandbox Code Playgroud)