1

In Node.js how can I stream multiple files in one response stream? I want to make a single api call from the browser application and in the response I should be able to send multiple files from the server. How can I do this in Node.js ? Please share some hints or code samples.

The files are stored as blob data in MongoDB and I use the module called gridfs-stream to read the files.

Aniz
  • 11
  • 4
  • To minimize bandwidth, you can zip the files server-side using a npm package like https://www.npmjs.com/package/bestzip and unzip them in the browser with libraries like zip.js https://gildas-lormeau.github.io/zip.js/ – widged Jan 05 '19 at 03:22
  • Sorry, I forgot to mention that the files are stored as blob data in MongoDB and I use the module called gridfs-stream to read the files. – Aniz Jan 05 '19 at 03:39
  • 1
    @Aniz perhaps HTTP multipart boundaries could help... another option is to use HTTP 2.0 in which you can actually send anything you like. Here's something close enough to nudge you in the right direction: https://stackoverflow.com/questions/47067312/multipart-http-response – Michał Karpacki Jan 09 '19 at 20:19

0 Answers0