title: Firebase cloud functions: how to retrieve a file from an FTP account and download it in the browser
body: <p>I have an app which has Firebase as a back-end. From within this app I connect to a FTP server.
  The connection to the FTP server is done using Firebase Cloud functions and the jsftp module (<a href="https://github.com/sergi/jsftp" rel="nofollow noreferrer">https://github.com/sergi/jsftp</a>).
  I have done tests and it works well to browse the files, create files or folder and upload new files.
  I got stuck with how to retrieve files from the server. In the jsftp module there is the get() method that is doing this and it is working like that:</p>
  
  <pre><code>var str = ""; // Will store the contents of the file
  ftp.get("remote/path/file.txt", (err, socket) =&gt; {
    if (err) {
      return;
    }
  
    socket.on("data", d =&gt; {
      str += d.toString();
    });
  
    socket.on("close", err =&gt; {
      if (hadErr) console.error("There was an error retrieving the file.");
    });
  
    socket.resume();
  });
  </code></pre>
  
  <p>The documentation says like this: <strong><em>Gives back a paused socket with the file contents ready to be streamed, or calls the callback with an error if not successful.</em></strong></p>
  
  <p>As I have limited experience with Nodejs and socket my question is: How can I retrieve the file using this "socket" and make it available for download in the browser.
  So when I call the Firebase Cloud function it should return the file. Is that possible? </p>
  
  <p>Thanks in advance!</p>