I'm looking to create static text files based upon the content of a supplied object, which can then be downloaded by the user. Here's what I was planning on doing:
When the user hits 'export' the application calls a
Meteor.method()
which, in turn, parses and writes the file to the public directory using typical Node methods.Once the file is created, in the callback from
Meteor.method()
I provide a link to the generated file. For example, 'public/userId/file.txt'. The user can then choose to download the file at that link.I then use Meteor's
Connect modele
(which it uses internally) to route any requests to the above URL to the file itself. I could do some permissions checking based on the userId and the logged in state of the user.
The problem: When static files are generated in public, the web page automatically reloads each time. I thought that it might make more sense to use something like Express to generate a REST endpoint, which could deal with creating the files. But then I'm not sure how to deal with permissions if I don't have access to the Meteor session data.
Any ideas on the best strategy here?