I am trying to upload a small image in base64 as a Chatter file (ContentVersion record where Origin = 'H') via the Force.com REST API.
Here are the headers and body that I am sending: https://gist.github.com/lukemcfarlane/4ab87a67e6bf3ef9eb83
I am testing this using a Mac REST client called RESTed (https://github.com/hellopatrick/rested), and I am getting back a successful response:
HTTP/1.1 201 Created
{
"id": "068R0000000Dk7lIAC",
"success": true,
"errors": []
}
I then find the file under Chatter > Files in Salesforce and it exists, however when I download and try to open the file I get an error message saying that the file is damaged and cannot be opened.
I am closely following the example in the following documentation: http://www.salesforce.com/us/developer/docs/api_rest/index_Left.htm#CSHID=dome_sobject_insert_update_blob.htm|StartTopic=Content%2Fdome_sobject_insert_update_blob.htm|SkinName=webhelp
One question I have is, where it says "Updated document binary data goes here." should that be base64 encoded binary data? If so then what else could be going wrong?
Update
I opened the "damaged" file with a text editor on my local machine and observed that the file consists of the original base64 data that I uploaded. This tells me that the API must not be decoding my base64 into a binary file.