I\'m working on a website using nodejs and SailsJs.
My objective is send the blobs generated by MediaRecorder.ondataavailable event (which returns small blobs) to the se
This is my solution if it helps anybody:
I send chuncks in binary format (I have selected Uint8Array), and add each chunk to a file in the server side after packing the received data (converted to binary in the same unsigned char decoding)
Client Side Javascript:
let order=0;
mediaRecorder.ondataavailable = async (e) => {
if(e.data && e.data.size > 0) {
var reader = new FileReader();
reader.readAsArrayBuffer(e.data);
reader.onloadend = async function(event) {
let arrayBuffer = reader.result;
let uint8View = new Uint8Array(arrayBuffer);
let response = await fetch('save-video.php', {
method: 'POST',
body: JSON.stringify({
chunk: uint8View,
order: order
})
});
order += 1;
}
}
}
Server Side PHP: