Get files from Private folder

So I want to display some .pdf content, that can be only available in the private folder.

Im trying using assets, but it gets the content from the pdf, not the file.

Here some of the code:

This method on server

 getPdf : function(){

    var data = Assets.getText('someFile.pdf');
    return data;

this call on client:'getPdf', function(error,result) {
   data = result;

I want the same functionality as files from /public folder, but in /private, something like this:

<a href="{{data}}" target="_blank" ></a>

Is it possible?


You could do something like this (for this example I’m assuming you have a file called meteor.pdf in your private directory - and please note, this is a quick example; I’m skipping over proper error handling, etc.):



  <a href="#" class="js-download-pdf">Download PDF</a>


if (Meteor.isClient) {{
    'click .js-download-pdf'(event) {
      event.preventDefault();'downloadPdf', (error, pdf) => {`data:application/pdf;base64, ${pdf}`);

  downloadPdf() {
    if (!this.isSimulation) {
      const rawPdf = Assets.getBinary('meteor.pdf');
      const jsonPdf = EJSON.toJSONValue(rawPdf);
      return jsonPdf['$binary'];
1 Like

Thank you so much,

it is just what I needed!

Works perfectly!