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