Closed housan-eng closed 4 years ago
@houzhanshan, a "file stream" is actually a byte stream. Just make sure to keep all data on a buffer and then dump it wherever you want:
const buffer = new Buffer(0);
socket.on('data', (chunk) => {
buffer = Buffer.concat([buffer, chunk]);
});
socket.on('close', () => {
// Do something with the buffer
});
You can find more info on this gist
Thanks a lot, help me
Sorry to disturb you again, I need to transfer files using TCP, how do I handle the file stream to byte stream