I am trying to capture buffer of images from client application to server side (nodejs) and save it on local machine.
client code -
var imgStr = new Buffer(img).toString('base64');
var obj = {};
obj.image = imgStr;
socket.emit("screen-capture", JSON.stringify(obj));
server code (nodejs + express)-
let chunks = []
socket.on("screen-capture", function (data) {
data = JSON.parse(data);
var imgStr = data.image;
chunks.push(imgStr)
let buffer = Buffer.from(chunks, 'base64');
console.log('is this a buffer?', buffer instanceof Buffer) // Giving True
console.log("video size" + buffer.length) // Giving size
fs.writeFile(`testing.mp4`, buffer, () => console.log('finished downloading video!')); // file saved
})
But when will open the video file saved it shows empty.
any help is appreciated.