node.js - I am unable to convert http.get image into base 64 -
app.getimage = function() { var image = meteor.http.get("https://turtlerock-discourse.global.ssl.fastly.net/user_avatar/talk.turtlerockstudios.com/takran/45/879.png", { }); var prefix = "data:image/png;base64,"; var imagebase64 = new buffer(image.content, 'binary').tostring('base64'); imagebase64 = prefix + imagebase64; console.log(imagebase64); return imagebase64; }
but not seeing results, help? dummy text error.
a pure meteor solutions:
var response = http.call('get', url,{npmrequestoptions: { encoding: null }}) var data = "data:" + response.headers["content-type"] + ";base64," + new buffer(response.content).tostring('base64');
Comments
Post a Comment