2

I'm trying to download a file from a browser using socket.io-stream. In a basic form, this is actually doable and there is a working example here.

However, that solution:

  1. First streams the file contents to the browser using socket.io-stream.

  2. Assemble the chunks in the client as a blob.

  3. Create a hidden link to the blob location.

This forces the browser to contain the whole blob in memory before it can initiate the download. I'm working with really large blobs, so that is not advisable.

I would prefere to download the stream directly, instead of buffering it in memory in the browser.

Is that possible?

I know this is easy to do just with plain HTTP, but there are some reasons that make this simplest option not available in my case.

Sergeon
  • 6,638
  • 2
  • 23
  • 43
  • Did you find a solution? According to my researchs, there is no such implementation yet. Seems like I've to end with plain HTTP. Sad, since I need Websockets for real time information about the downloads and I've to authenticate the user both in WS and default HTTP requests... – Lion Feb 18 '18 at 10:59
  • 1
    @Lion, no, I didn't find any solution to address this with sockets. In that particular case, we just went back to plain http. – Sergeon Feb 18 '18 at 22:00
  • hey @Sergeon please man can u tell me how to do it with HTTP , would be great if there is a full example, am kind of in maze here , thanks in advance – Nasr Sep 02 '19 at 21:33
  • Hi @Nasr, the idea is that you specify some custom headers when serving the file through HTTP. Then, the browser deals with it and downloads the file in the user's machine automatically. There is this question about how to do this with node.js: https://stackoverflow.com/questions/7288814/download-a-file-from-nodejs-server-using-express . For other languages/stacks you will find similar tutorials searching in google. Good luck! – Sergeon Sep 02 '19 at 22:14
  • @Sergeon thanks buddy really apperciated , one other question, is it possible to download a file via FTP same time to stream the downloading data via for ex: socket io, so at the end, there a front end that shows the files that is being downloaded and the remaining and also the precengte ? is this possible? – Nasr Sep 03 '19 at 09:38
  • I have no idea about that :-S, sorry @Nasr! – Sergeon Sep 03 '19 at 11:43

0 Answers0