我在 S3 上存储了文件,我希望在用户单击按钮时自动下载这些文件
到目前为止我所做的是有一条路线
/lib/routes/download
var fs = Npm.require('fs');
Router.route("download", function() {
console.log('retrieving ' + this.params.signedURL);
this.response.writeHead(200, {'Content-type': 'appplication/pdf'}, this.params.signedURL);
this.response.end(fs.readFileSync(this.params.signedURL));
}, { where: 'server', path: '/d/:signedURL'});
但这不起作用,因为我无法在客户端上使用fs
。即使我可以,我也不确定这是否有效
关于如何最好地实现这一目标有什么建议吗?
最佳答案
最简单的方法是使用 cfs:s3 package这是 CollectionFS 的附加组件。这不仅支持 S3,而且在上传到 S3 或从 S3 下载时透明地将文件分成更小的 block 。
关于meteor - 单击强制从 S3 下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28927587/