fuweichin / node-save-blob

To save a Blob as file to the Downloads folder, for Node.js and browsers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-save-blob

To save a Blob as file to the Downloads folder, for Node.js and browsers

Inspired by navigator.msSaveBlob

Usage

In Node.js

import {saveBlob} from 'node-save-blob';

let blob = new Blob(['hello'], {type:'text/plain'});

let filePath = await saveBlob(blob, 'hello.txt'); 
console.log('downloaded as '+filePath);

In browsers

import {saveBlob} from 'node-save-blob';

let blob = new Blob(['hello'], {type:'text/plain'});

let started = saveBlob(blob, 'hello.txt');
console.log('download '+(started?'started':'failed'));

License

MIT

About

To save a Blob as file to the Downloads folder, for Node.js and browsers

License:MIT License


Languages

Language:JavaScript 84.0%Language:HTML 16.0%