Last active
June 30, 2018 20:12
-
-
Save thihenos/ad76d8f65d5ddd3a365717e5e065532d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
//Convertendo binario em arquivo | |
function base64_decode(base64str,fileName){ | |
var bitmap = new Buffer (base64str, 'base64'); | |
fs.writeFileSync('src/temp/'+fileName+'',bitmap, 'binary', function (err){ | |
if(err){ | |
console.log('Conversao com erro'); | |
} | |
} ); | |
} | |
//Convertendo arquivo em binário | |
function base64_encode(fileName){ | |
var bitmap = fs.readFileSync('src/temp/'+fileName+''); | |
return new Buffer (bitmap).toString('base64'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment