//ENCODE
// read binary data
// this on server
const bitmap = fs.readFileSync(file);
// convert binary data to base64 encoded string
const attachmentBase64 = new Buffer(bitmap).toString('base64');
//DECODE
// this on client
const base64str = result;
const bitmap0 = new Buffer(base64str, 'base64');