I am using node.js (aws lambda) to perform a simple get request for a .png image on an external server. The data that I'm getting back seems to be encoded incorrectly, but I cant figure out how or why to get the correct encoding. the length and structure of the data seems to be the same (as shown in the images), but I just cant figure out why I dont get the same data...ive tried converting to base64, utf-8, etc.
my function:
http.get(FinalURL, function(res) {
res.on('data', function(d) {
body += d;
});
res.on('end', function() {
resolve(body);
});
res.on('error', function(e) {
resolve(e.message);
});
});
I was able to get it to work by downloading it as binary using
res.setEncoding('binary');
i think this simplifies the characters and then its able to understand what its downloading