How to save the video blob in nodejs?
Closed this issue · 1 comments
robfuncken commented
Im trying to post the video blob to my nextjs api, to save it on the server. Unfortunately I cannot get it to work. Does anyone know the solution?
<VideoRecorder onRecordingComplete={(videoBlob) => { // Do something with the video... fetch("/api/video", { method: "post", body: videoBlob, }) .then(function (response) { console.log("done"); return response; }) .catch(function (err) { console.log('error', err); }); }} />
and on the server side:
fs.writeFile('test', req.body, function (err) { if (err) return console.log(err); console.log('video saved'); } );
slavaGanzin commented
For anybody who would find this issue, you can use multer and fetch:
const fd = new FormData();
fd.append('video', blob, 'name.webm')
fetch('/upload/video', { method: "POST", body: fd})