How to return a file for download to the client from a meteor method


#1

Hello everyone,
I have some PDF files on the server and I want to send them to the client to download them, but I can’t figure out a way to do it.

I found a way to send the file as a base 64 String but it dosn’t prompt the client for download.
my code:

Meteor.methods({

getPDF(id) {
            var fs = Meteor.npmRequire('fs');
            var Future = Meteor.npmRequire('fibers/future');
            var fut = new Future();
            var fileName = PATH+this.userId + "_" + id + ".pdf";
            fs.readFile(fileName, function (err, data) {
            if (err) {
                console.log(err);
                fut.throw(err);
               }
               fs.unlinkSync(fileName);
               fut.return(data);
              });
            let pdfData = fut.wait();
            let base64String = new Buffer(pdfData).toString('base64');
            return base64String;
        }
}

});

Have anyone idea on how to prompet the client to download the file ?

please forgive my poor english