blob-url-file

1.0.0 • Public • Published

js-file

transformation functions of file/blob/base64

usage

npm install blob-url-to-file

import { blobToBase64 } from 'blob-url-to-file'

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);

/blob-url-file/

    Package Sidebar

    Install

    npm i blob-url-file

    Weekly Downloads

    124

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    7.83 kB

    Total Files

    4

    Last publish

    Collaborators

    • weituoyeben