zer02 zer02 - 1 year ago 392
Javascript Question

Node.js can´t create Blobs?

I am working with node.js and I streamed my Audio to my node.js server.
Now I noticed during the process of building the audio blob:

var audioBlob = new Blob([dataview], { type: 'audio/wav' });

That I get a ReferenceError at new Blob.
It seems that Blob is not supported.
How can I create a blob which I would like to save with node.js fs module.

Thanks guys!

Answer Source

The Solution to this problem is to create a function which can convert between Array Buffers and Node Buffers. :)

Convert a binary NodeJS Buffer to JavaScript ArrayBuffer

In recent node versions it's just:

let buffer = Buffer.from(arraybuffer);
let arraybuffer = Uint8Array.from(buffer).buffer;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download