dataurify
v1.0.4
Published
Turn a buffer into a data URI
Downloads
33
Readme
dataurify
Turn a buffer into a data URI
Usage
'use strict'
var hyperquest = require('hyperquest')
var dataurify = require('./index')
var buffer = []
var req = hyperquest.get('http://video.webmfiles.org/big-buck-bunny_trailer.webm')
req.on('response', function (res) {
res.on('data', function (chunk) {
buffer.push(chunk)
})
res.on('end', function () {
console.log(dataurify(Buffer.concat(buffer))) // data:video/webm;base64,...
})
})
Install
$ npm install dataurify
Supported types
https://github.com/sindresorhus/file-type#supported-file-types
API
dataurify(buffer)
Pass in a single buffer
and get back a functional data URI. Check supported types
to see if your content is supported.
License
MIT