Closed MessShawn closed 8 years ago
Can you post the code, and the errors you're seeing in the JavaScript Console?
here is the code: and logs:
it's a cordova app running on ios device
The error seems to be throwned by jQuery response convertor. What confused me is that is there a standard method that the forcetk offered to fetch attachment body as the retrieve method can not get the data?
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 https://github.com/developerforce/Force.com-JavaScript-REST-Toolkit/issues/81#issuecomment-156336321 .
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.
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?