Skip to content

banzeh/file-base64-promise

 
 

Repository files navigation

  • 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')

About

Encode or Decode base64 use stream

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%