title: Download PDF from node API via FTP
body: <p>I have PDF on a remote server. I have API with node and I want, from my website, download the PDF.</p>
  
  <p>I'm using <code>jsftp</code> to upload and read PDF. It works fine :</p>
  
  <pre><code>let str = '';
  FTP.get('path/to/my/file', (err, socket) =&gt; {
      socket.on("data", d =&gt; {
          str += d.toString();
      });
      socket.on("close", err =&gt; {
          if (err) {
              console.error("There was an error retrieving the file.", err);
          }
          // HERE I HAVE THE FILE IN STRING
      });
      socket.resume();
  });
  </code></pre>
  
  <p>On the close event I have the file in String, but I don't succeed to send it to the browser. I've tried things like :</p>
  
  <pre><code>let s = new Readable();
  s.push(str);
  s.push(null);
  s.pipe(res);
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>res.end(str);
  </code></pre>
  
  <p>But nothing happen in browser</p>
  
  <p>I'm using Polymer for my ajax request</p>
  
  <pre><code>&lt;iron-ajax
      id="openPdf"
      content-type="application/json"
      method="POST"
      url="/api/karaweb/pdf"
      on-response="handleOpenPdfResponse"
      on-error="errorMessage"&gt;&lt;/webservice-request&gt; 
  </code></pre>
  
  <p>Any solutions ?</p>
  
  <p>Thanks</p>