I'm trying to encode an image using base64 in Node.JS to pass along to the PostageApp API as an attachment. I thought I had it working but it attaches a 1K file that isn't exactly what I was looking for.
Here's my code:
var base64data;
fs.readFile(attachment, function(err, data) {
base64data = new Buffer(data).toString('base64');
});
And here's the part of the API call I am making:
attachments: {
"attachment.txt" : {
content_type: "application/octet-stream",
content: base64data
},
}
I'm a bit lost, not being so great with Node, but I thought it would work. Any help would be appreciated!