Crash Override
Crash Override

Reputation: 1427

Meteor download binaries from server?

Using Meteor and Iron Router, is there a Meteor module that makes it easy to serve up binary files for download on the local filesystem, outside of the Meteor app container?

So if the Meteor app is in /home/meteor/app is it possible to provide download links to /data/files within Meteor?

I'm guessing the answer is No since it appears Meteor isolates itself within its container, but figured I'd ask.

I don't want to put the files in Meteor's /public because they need to be in a network folder, outside of the Meteor app itself.

Upvotes: 0

Views: 342

Answers (1)

Alex028502
Alex028502

Reputation: 3824

It doesn't directly answer the question, but I did it like this. There might be a better iron router way.

WebApp.connectHandlers.use('/filename.txt', function(req, res, next) {
  //the filename in the url and the filename on disk don't have to be
  //the same but I made them the same here

  var fs = Npm.require('fs');

  var data = fs.readFileSync("/path/to/filename.txt");

  //if it's in the project's private directory,
  //or if you are working in a package and you added filename.txt with addAssets
  //you can probably just use
  //var data = Assets.getBinary("filename.txt");

  res.write(data);
  res.end();

});

Upvotes: 0

Related Questions