blob-url-to-file

1.0.0 • Public • Published

js-file

transformation functions of file/blob/base64

blobToBase64

const b64Data = await blobToBase64(blob); 

urlToBlob

const blob = await urlToBlob(url); // url is a dataUrl, like: 'data:application/json;base64,ewogICJoZWxsbyI6ICJ3b3JsZCIKfQ==';

base64ToBlob

const blob = await base64ToBlob({ b64Data="", contentType="", sliceSize=512, name=""}); // b64Data is required;

fileUrlToUrl(fileUrl)

const fileUrl = 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Falco_peregrinus_-_01.jpg/1920px-Falco_peregrinus_-_01.jpg';
const url = await fileUrlToUrl(fileUrl);

downloadFile(fileUrl, name)

// autodownload
const fileUrl = 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Falco_peregrinus_-_01.jpg/1920px-Falco_peregrinus_-_01.jpg';
downloadFile(fileUrl, name);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.014latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.014

Package Sidebar

Install

npm i blob-url-to-file

Weekly Downloads

14

Version

1.0.0

License

MIT

Unpacked Size

7.68 kB

Total Files

4

Last publish

Collaborators

  • weituoyeben