I have a server side route that generates a pdf, let’s call it ‘/server/pdf’. This route serves the pdf as a ‘Content-Type’: application/pdf, and delivers it inline (‘Content-Disposition’: inline), meaning the file is displayed in the browser instead of being downloaded.
I want to attach this pdf to an email. Is there a way I can grab the pdf file from the browser or from the server without having to save the file in permanent storage (i.e., upload to Amazon S3)? I want something to the effect of:
on the client:
Template.sendEmail.events({
'click #send-button': function(event) {
event.preventDefault();
// some code to grab pdf file from url '/server/pdf'
var file = download.file('/server/pdf');
Meteor.call('sendEmail', file, function(error, result) {
// handle error
});
}
});
OR, on the server:
Meteor.methods({
'sendEmail': function() {
// some code to grab pdf file from url '/server/pdf'
var file = download.file('/server/pdf');
Email.send(...);
}
});