nkzawa / socket.io-stream

Stream for Socket.IO
MIT License
612 stars 111 forks source link

Can I upload a file and append it to the previous one? #97

Open SalvatoreAD opened 7 years ago

SalvatoreAD commented 7 years ago

Hi, I'm trying to save the blob files in a given interval on the server and link them to create a single file.

The scenario is this: A video conference with 5 participants, the conference is being recorded every 60 seconds and loads the blob on the server and chained to the previous to create 5 files (one for each participant)

On the client side:

var stream = ss.createStream(); ss(socket).emit('file:add:stream', stream, elem, roomId); var blobReadStream = ss.createBlobReadStream(video); console.debug(blobReadStream); blobReadStream.pipe(stream); console.debug(stream); ss(socket).on('file:add:stream:success', function(data) { console.info('file uploaded to server'); });

The server side:

ss(socket).on("file:add:stream", function(stream, data, roomId) { console.log(stream); var dataStream = fs.createWriteStream('./public/uploads/'+roomId+"/"+data+".webm", { 'flags': 'a' }); stream.pipe(dataStream); ss(socket).emit('file:add:stream:success'); });

Can you help me figure out the error? Thanks