jimmywarting / StreamSaver.js

StreamSaver writes stream to the filesystem directly asynchronous
https://jimmywarting.github.io/StreamSaver.js/example.html
MIT License
3.97k stars 413 forks source link

Save stream from socket.io stream package to the file #278

Closed CapLek closed 2 years ago

CapLek commented 2 years ago

In the browser I'm requesting pretty large binary file (~1 Gb) from a server through socket.io stream. It's being streamed by chunks. Is it possible to save it to the file directly not via saving to Blob first?

I've tried it this way and in it didn't work.

const socketStream = reqiure('socket.io-stream')

const fileStream = streamSaver.createWriteStream('filename.zip')
const targetStream = socketStream.createsStream() // Readable-writable stream
socketStream(socket).emit('get-large-file', targetStream)
targetStream.pipe(fileStream)

Maybe I'm missing something? Thank you.