How to create blobs with Node.js and JavaScript?

Spread the love

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

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

How to create blobs with Node.js and JavaScript?

To create blobs with Node.js and JavaScript, we use the node:buffer module.

For instance, we write

import { Blob } from "node:buffer";

const blob = new Blob([]);

to import the Blob constructor and create an object from it.

We use the cross-blob package for Node versions older than 16.

To install it, we run

npm i cross-blob

Then we use it by writing

import Blob from "cross-blob";

const blob = new Blob([]);

Conclusion

To create blobs with Node.js and JavaScript, we use the node:buffer module.

Leave a Reply

Your email address will not be published. Required fields are marked *