- Encode a file to a base64 string using promise
- Decode a base64 string to a file using promise
$ npm install promise-base64 --save
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')
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')