https://github.com/ragingwind/data-uri-to-file
data-uri encoded in base64 to file or stream
https://github.com/ragingwind/data-uri-to-file
Last synced: about 1 year ago
JSON representation
data-uri encoded in base64 to file or stream
- Host: GitHub
- URL: https://github.com/ragingwind/data-uri-to-file
- Owner: ragingwind
- License: mit
- Created: 2015-12-11T23:10:47.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-05T13:17:07.000Z (almost 9 years ago)
- Last Synced: 2025-04-25T10:54:52.650Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# data-uri-to-file [](https://travis-ci.org/ragingwind/data-uri-to-file)
> data-uri encoded in base64 to file or stream
## Install
```
$ npm install --save data-uri-to-file
```
## Usage
```js
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](http://ragingwind.me)