Skip to content

Neilblaze/buffer2url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

buffer2url | @npm_node.js

License Build status Commits since v1.0.0 Last commit Issues
Latest version on npm Downloads

Creates a data URL (base64-encoded) from a Buffer and a mimetype for Node.js.

Installation

buffer2url on npm

npm install --save buffer2url@^1.0.0

buffer2url on Yarn

yarn add buffer2url@^1.0.0

@Neilblaze/buffer2url on GitHub Packages
(if configured properly)

npm install --save @Neilblaze/buffer2url@^1.0.0

Example

import buffer2url from "buffer2url"

const imageBuffer = fs.readFileSync("pikachu_8x8.png")
const dataUrl = buffer2Url("image/png", imageBuffer)

Variable result will be:

"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAARklEQVQoU2P8/Z/hPwMewEiUAhaG/wyMjIwMv6FmIfPBJrAyQuyAKUDmo1iBrhCkifG/oBrY4D/vbqE4lUVIDcwnrICQLwAWoihJ/lJMVwAAAABJRU5ErkJgggAA"

Development

Setting up:

git clone git@github.com:Neilblaze/buffer2url.git
cd buffer2url
npm install

Testing:

npm run test:dev

Testing in production environment:

npm run test

License

MIT License
Copyright © 2020, Neilblaze <neilblaze007@gmail.com> (https://github.com/Neilblaze)

About

Creates a data URL (base64-encoded) from a Buffer and a mimetype for Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors