I am using a library to recieve attachments (image) from salesforce using OAuth and a proxy. Without the library (and the proxy) I am able to the same using XHR, but I have to use the library because I need the proxy.
In chrome debugger I can see image is downloaded fine, but I can't get it to work in my code. Data looks like:
So far methods I have tried:
btoa(unescape(encodeURIComponent(file.body)));
- produces a base64 that does not work. decoding it using online tools gives me back the same string.escape(file.body)
- using this as base64 also does not work.Converting to a blob.
var blob = new Blob([file.body], {type : "image/png"}); urlCreator.createObjectURL(blob);
The url it points to displays nothing, and if I remove{type : "image/png"}
the url points to a page displaying same binary string.