The Google API I'm using is transmitting images only as binary data.
I have absolutly no idea how to put this into a data URI to display it, thanks for any help!
The call I'm talking about is this API call.
As you can see, it says:
The server returns bytes of the photo.
For the call (it's an extension), I use the chrome_ex_oauth methods. Maybe I need to add something into the header to get real binary data, not string as it comes in right now...
What I need to do is to convert the resulting binary into data URI so I can display it.
Ok, I get this out of the XHR request
Now, I dont know binary stuff much. This is somehow encoded binary data i assume? I tried to put this into btoa and other base64 encoders, everything throws an error.
I tried to overrideMimeType with different things and the "response" changed in some strange ways, but nothing accepts the data.
So now I have this code:
var nxhr = new XMLHttpRequest();
nxhr.onreadystatechange = function (data) {
if (nxhr.readyState == 4) {
console.log(nxhr);
}
};
nxhr.open(method, url, true);
nxhr.setRequestHeader('GData-Version', '3.0');
nxhr.setRequestHeader('Authorization', oauth.getAuthorizationHeader(url, method, params));
nxhr.send('Data to send');
Anybody else has any idea how to get this for me not understandable response into a data uri???
Thanks for any help
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…