I am consuming third party service for downloading images but body of it's response includes html plus base64(not sure) image content on top. Response has content type as image/jpeg; charset=utf-8
Example response:
����JFIF``��C
$.' ",#(7),01444'9=82<.342��C
2!!22222222222222222222222222222222222222222222222222��"��
���}!1AQa"q2���#B��R��$3br�
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz���������������������������������������������������������������������������
���w!1AQaq"2�B���� #3R�br�
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body onload="initslide('method1,method2,method3', '');">
// More html goes here
</body>
</html>
And service call:
var params = {
url : serviceUrl,
form : form,
headers : headers
};
request.post(params, function(error, response, body) {
if (error) {
console.error("Error:", error);
return;
}
callback(body); // In body i am getting above response
});
Now, I am only interested in downloading image portion of it and save it on cloud as png/jpeg format. Any idea how to achieve this in node.js.