promise-base64
v1.0.2
Published
encode a file to base64 string or decode a base64 string to file.
Downloads
22
Readme
- Encode a file to a base64 string using promise
- Decode a base64 string to a file using promise
Install
$ npm install promise-base64 --save
Usage
Encode
var base64 = require('promise-base64');
base64.encode('./text.txt')
.then((base64String) => {
console.log(base64String)
})
.catch((err) => {
console.log(err)
})
Or using await
const base64String = await base64.encode('./text.txt')
Decode
var base64String = 'swesh523sfsfgwg';
base64.decode(base64String, 'text.new.txt')
.then((base64String) => {
console.log(base64String)
})
.catch((err) => {
console.log(err)
})
Or using await
await base64.encode(base64String, './text.await.txt')