允许用户从公用文件夹Meteor.js下载文件 [英] Allow user to download file from public folder Meteor.js

查看:127
本文介绍了允许用户从公用文件夹Meteor.js下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在生成一个.xlsx文件,然后将其放入"../web.browser/app/cheques.xlsx".据我了解,它等效于构建中的公用文件夹.问题是我无法使其可供下载.

I am generating a .xlsx file and then place it into "../web.browser/app/cheques.xlsx". As I understand it is an equivalent of public folder inside the build. The problem is that I can't manage to make it available for download.

这是服务器方法中的代码片段,我在其中放置文件:

This is a fragment of code in server method, where I place a file into that place:

workbook.xlsx.writeFile("../web.browser/app/cheques.xlsx")
  .then(function() {
    console.log('done');
  });

那么我应该使用fs还是Picker.route来完成这项工作?

So should I use fs or Picker.route to do the job?

推荐答案

不建议这样做.在生产环境中,您将始终无法使用构建目录.

It's not advisable to do this. In production the build directory won't be available to you anyway.

您有几种选择:

  1. 将文件存储在文件系统中的已定义位置(不是 /public),其他类似Apache的服务也可以
  2. 存储 S3存储桶中的文件,然后让AWS为它们提供服务
  3. 使用类似的包将文件存储在Mongo集合中 https://github.com/vsivsi/meteor-file-collection
  1. Store the files in a defined place in the file system (not /public) that something else like Apache can serve from
  2. Store the files in an Amazon S3 bucket, and then let AWS serve them
  3. Store the files in a Mongo collection, uing a package like this https://github.com/vsivsi/meteor-file-collection

我喜欢最后一个,因为您所有的数据和文件都放在一个地方.

I prefer the last one, as all your data and files are in one place.

这篇关于允许用户从公用文件夹Meteor.js下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆