How to create blobs with Node.js?

Sometimes, we want to create blobs with Node.js.

In this article, we’ll look at how to create blobs with Node.js.

How to create blobs with Node.js?

To create blobs with Node.js, we can use the Buffer.from method.

For instance, we write

const buffer = Buffer.from(arrBuffer);
const arrayBuffer = Uint8Array.from(buffer).buffer;

to call Buffer.from with the arrBuffer array buffer object to create a buffer.

Then we call Uint8Array.from with a buffer to convert the buffer to an Uint8Array and get the array buffer with the buffer property.

Conclusion

To create blobs with Node.js, we can use the Buffer.from method.