Retrive method can not transfer attchment base64 string body correctly
MessShawn opened this issue · comments
I've got an issue to download attachment body in our app.
We use forcetk retrieve method and never got the body data but the uri(something like '/services/data/v33.0/sobjects/Attachment/00P25000000aiNREAY/Body').
Then I use the ajax method of forcetk client directly to call the resource 'services/data/v33.0/sobjects/Attachment/00P25000000aiNREAY/Body' and every time it results to error handling function. it seems that the responseText is right but when I use btoa(unescape(encodeURIComponent(XXX))) to convert the result into base64 string, the converted data is never matches correct .
Would you give me some advice here?
Can you post the code, and the errors you're seeing in the JavaScript Console?
The problem is that the query returns binary data, rather than text (see the docs). You should be able to use getChatterFile instead of ajax.
@metadaddy-sfdc I've solved the problem, thanks a lot~
What did you need to change?
On Thursday, November 12, 2015, Simon Xiao notifications@github.com wrote:
@metadaddy-sfdc https://github.com/metadaddy-sfdc I've solved the
problem, thanks a lot~—
Reply to this email directly or view it on GitHub
#81 (comment)
.
Cheers,
Pat
@metadaddy-sfdc use the getChatterFile method to download attachment body and convert the response data as array buffer directly.
Great! Closing the issue, since it seems like you're all set.