[Javascript]Blob to File and File to Blob

blob and file


In this article, I am going to describe about how to convert Blob to File and how to convert File to Blob.
Both are easy to do.


Table of Contents

Blob to File

const blob = new Blob(['hoge'], { type: 'text/plain' })
const file = new File([blob], 'sample.txt', { type: blob.type })




File to Blob

const file = new File(['hoge'], 'sample.txt', { type: 'text/plain' })
const blob = new Blob([file], { type: file.type })




That is all,  it was about how to convert Blob to File and how to convert File to Blob.

Sponsored Link

You can subscribe by SNS

Sponcerd Link