Skip to content
Advertisement

How to convert Blob to File in JavaScript

I need to upload an image to NodeJS server to some directory. I am using connect-busboy node module for that.

I had the dataURL of the image that I converted to blob using the following code:

JavaScript

I need a way to convert the blob to a file to upload the image.

Could somebody help me with it?

Advertisement

Answer

This function converts a Blob into a File and it works great for me.

Vanilla JavaScript

JavaScript

TypeScript (with proper typings)

JavaScript

Usage

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement