Search code examples
node.jsmeteorfsexceljs

Allow user to download file from public folder Meteor.js


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');
  });

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


Solution

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

    You have a few choices:

    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.