data-uri-to-file

0.1.8 • Public • Published

data-uri-to-file Build Status

data-uri encoded in base64 to file or stream

Install

$ npm install --save data-uri-to-file

Usage

const toFile = require('data-uri-to-file');
const dataUri = 'data:image/svg+xml;base64,PD94bWwgdmVy ... URPQ1RZUEUgc3ZnIFB4KPC9zdmc+Cgo=';
 
// promise style
toFile(dataUri).then(file => {
    console.log(file.mimeType, file.data, file.extension);
});
 
// stream style
fs.createReadStream('data-uri')
    .pipe(toFile.stream())
    .pipe(createWriteStream('file.svg'));

API

toFile(input)

input

Type: string

String with data-uri encoded in base64.

toFile.stream()

Stream supportable interface.

License

MIT © ragingwind

Package Sidebar

Install

npm i data-uri-to-file

Weekly Downloads

103

Version

0.1.8

License

MIT

Last publish

Collaborators

  • ragingwind