I'm trying to render a PDF to the browser with Meteor 1.0.3, Iron Router (IR), using S3 as the storage location of the pdf.
Context
I have this process working without S3, only using a server side directory, but would now like to incorporate S3 for storage.
I currently have my generated file located here for example:
application-name/server/.files/users/user-name/test.pdf
I use IR on a server side path to render the pdf like so:
Router.route('/test-pdf', function() {
if(!user) return this.response.end("Not allowed");
var filePath = process.env.PWD + "/server/.files/users/" + userId + "/" + "test.pdf";
console.log(filePath);
var fs = Npm.require('fs');
var data = fs.readFileSync(filePath);
this.response.write(data);
this.response.end();
}, {name: 'test-pdf', where: 'server'});
Packages
I looked at using Lepozepo/S3 or even eluck/meteor-aws-sdk, but haven't decided based on what I know at the moment.
In particular, Lepozepo/S3, seems to dedicated to S3, so I'm leaning this way for now.
Lepozepo/S3 seems simple enough to set up, but I'm not sure how to use it to 'get' or 'stream' the file from S3 and render it to the browser correctly.
I see in Lepozepo/S3 API calls to 'stream', 'upload', and 'delete', but no real examples of what seems to be what I need, which would be I think either 'stream' or download.
Question
How can I render a PDF to the browser using Lepozepo/S3 API calls using a IR route in Meteor?
Aucun commentaire:
Enregistrer un commentaire