0

I have tried to convert blobs to image file using the below code.

var file = new File([blobs],"Download.png");

This gives me a file with type null

This is my file in console.

lastModified: 1618930293005
lastModifiedDate: Tue Apr 20 2021 07:51:33 GMT-0700 (Pacific Daylight Time) {}
name: "Download.png"
size: 3
type: ""
webkitRelativePath: ""

While I'm trying to download this file, it is downloading as a text file and not an image file. Can somebody help me with this?

I want to download the original file (i.e., Image file)

0stone0
  • 34,288
  • 4
  • 39
  • 64
DeepS
  • 17
  • 3
  • Does this answer your question? [Show image from blob in javascript](https://stackoverflow.com/questions/4478863/show-image-from-blob-in-javascript) – 0stone0 Apr 20 '21 at 15:05

1 Answers1

1

You can specify the type in the third parameter:

 new File([blobs], "Download.png", { type: "image/png" })
Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151