https://github.com/neilblaze/buffer2url
Creates a data URL (base64-encoded) from a Buffer and a mimetype for Node.js
https://github.com/neilblaze/buffer2url
Last synced: 3 months ago
JSON representation
Creates a data URL (base64-encoded) from a Buffer and a mimetype for Node.js
- Host: GitHub
- URL: https://github.com/neilblaze/buffer2url
- Owner: Neilblaze
- License: mit
- Created: 2020-05-03T16:11:18.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-06T09:54:34.000Z (about 6 years ago)
- Last Synced: 2025-09-11T13:54:42.300Z (9 months ago)
- Homepage: https://www.pkgstats.com/pkg:buffer2url
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# buffer2url | @npm_node.js
**Creates a data URL (base64-encoded) from a Buffer and a mimetype for Node.js.**
## Installation
```bash
npm install --save buffer2url@^1.0.0
```
```bash
yarn add buffer2url@^1.0.0
```
(if [configured properly](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-npm-for-use-with-github-packages))
```bash
npm install --save @Neilblaze/buffer2url@^1.0.0
```
## Example
```javascript
import buffer2url from "buffer2url"
const imageBuffer = fs.readFileSync("pikachu_8x8.png")
const dataUrl = buffer2Url("image/png", imageBuffer)
```
Variable `result` will be:
```javascript
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAARklEQVQoU2P8/Z/hPwMewEiUAhaG/wyMjIwMv6FmIfPBJrAyQuyAKUDmo1iBrhCkifG/oBrY4D/vbqE4lUVIDcwnrICQLwAWoihJ/lJMVwAAAABJRU5ErkJgggAA"
```
## Development
Setting up:
```bash
git clone git@github.com:Neilblaze/buffer2url.git
cd buffer2url
npm install
```
Testing:
```bash
npm run test:dev
```
Testing in production environment:
```bash
npm run test
```
## License
[MIT License](https://raw.githubusercontent.com/Neilblaze/buffer2url/master/license.txt)
Copyright © 2020, Neilblaze \ (https://github.com/Neilblaze)