REST image upload of base64 file not recognised - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Sean WilliamsSean Williams 

REST image upload of base64 file not recognised

I am using REST service "/services/data/v41.0/connect/files/users/me" to upload a base64 encoded image file.  The upload works and i can see the file under the Files tab, but it is not recognised as an image file, and when downloaded it is the base64 characters.  It seems the REST upload is not converting the base64 data back into a native png graphics file.

Any idea why or how i solve this?

I am posting these headers and body:

Headers:
Content-Type: multipart/form-data; boundary=boundary_string

Body:
--boundary_string
Content-Disposition: form-data; name="entity_content";
Content-Type: application/json

{
    "title": "sean"
}

--boundary_string
Content-Type: application/octet-stream; charset=ISO-8859-1
Content-Disposition: form-data; name="fileData"; filename="image.png"
Content-Transfer-Encoding: binary

<base64 data here>
--boundary_string--
Jeff MayJeff May
Thank you for posting to Trailblazer Community.   This Community is focused on configuration and design questions. Programmatic questions are best submitted to the developer forums at https://developer.salesforce.com where the forums and participants are geared toward programming troubleshooting and support. 
Peter SteinebachPeter Steinebach

Hi Jean,

i wonder if you ever got an answer here that solves the issue.

I'm exactly at the same point: uploading to ContentVersion, using a base64 encoded jpg, having this 'base64-text' in my JSON and ending up with some corrupted content in SF - no preview and corrupted when downloading.

thx for any help here,

Peter