So using https://developer.api.autodesk.com/oss/v2/buckets/:bucketKey/objects/:objectName and javascript - I have returned a binary image that will not save. I have used fs, btoa, base64 and a few others but all the saved files error with unrecognized format.
Image Error No matter what i try i get this error, except if i use postman and use saveas. I have been searching why this works in postman but i cannot seem to find any reliable answer. So
this is what i have
try {
var data = null;
var access_token = JSON.parse(Atoken);
var settingspho = {
"url": "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/" + urnid,
"method": "GET",
"timeout": 0,
"headers": {
"Authorization": "Bearer " + access_token.access_token,
"Content-Type": "application/json"
},
};
$.ajax(settingspho).done(function (response, body) {
var data = 'data:image/jpeg;base64,' + btoa(response);
\\ tried this too \\var buf = new Buffer(data, 'base64');
const jsonfile = './photos/' + urnid;
fs.writeFile(jsonfile,buf, function (err) {
if (err) throw err;
});
});
}
catch (err) {
alert(err);
}
Here is a snapshot of the responsePostman Body Response