Skip to content

Instantly share code, notes, and snippets.

@amolv
Last active August 29, 2015 14:23
Show Gist options
  • Save amolv/7904b66d546909fe27e0 to your computer and use it in GitHub Desktop.
Save amolv/7904b66d546909fe27e0 to your computer and use it in GitHub Desktop.
base64 from image url
var request = require('request').defaults({ encoding: null });
console.log('sdsd');
request.get('https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfa1/v/t1.0-1/p50x50/11137188_892297130831688_6090481414515575407_n.jpg?oh=eb45d6cb986974706c22499a2842cb32&oe=561EA1E5&__gda__=1444782261_6afd6928d13aeadfe33393128852729b', function (error, response, body) {
console.log( error);
console.log( response.statusCode);
if (!error && response.statusCode == 200) {
data = "data:" + response.headers["content-type"] + ";base64," + new Buffer(body).toString('base64');
console.log(data);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment