Answer the question
In order to leave comments, you need to log in
BinaryData Buffer how to assemble into one?
Please tell me how to correctly assemble the final file that comes from the socket in chunks (pieces).
connection.on('message', (message)=>{
// console.log(message);
if (message.type === 'binary'){
// console.log(message.binaryData)
// binaryAudio = Buffer.concat(binaryAudio, message.binaryData)
// binaryAudio = binaryAudio .concat(binaryAudio, message.binaryData)
// binaryAudio.push(message.binaryData)
//binaryAudio += message.binaryData.toString()
// binaryAudio.append(message.binaryData.toString())
}
if (message.type === 'utf8' && JSON.parse(message.utf8Data).streamcontrol){
// console.log(binaryAudio.length)
// binaryAudio = [];
// res.end('');
res.statusCode = 200;
res.setHeader('content-type', 'audio/opus');
res.setHeader('Content-Disposition', 'attachment; filename=file.ogg');
res.setHeader("Content-Length", binaryAudio.toString().length);
// res.end(binaryAudio);
// res.end(binaryAudio.toString());
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question