function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dfpittdfpitt 

Importing Image into Salesforce via the API

How can I import an image into salesforce via the API?

 

I want to be able to import the image via the API and attach it to a custom object. Once attached, I already have a VF page in place that shows the Image.

 

Any help would be greatly appreciated.

 

Daniel

sfdcfoxsfdcfox

Place the file name in the "Body" field, then use the data loader. Or, if you're using your own integration, just remember you have to base-64 encode the binary data into the SOAP message. Could you elbaorate on the means you're using? I'm sure we could point you in the right direction.

dfpittdfpitt

Hello,

 

Thanks for the reply.

 

I need to do this programatically via the API. 

 

On an on-going basis, an external website will receive images and we need to save them within salesforce, preferably as attachments to custom objects.

 

I'm assuming from your message that i should encode the image to base64 and have base64 be the data type of the parameter in the webservice that receives the image. 

 

Then I can create an attachment in APEX, set the body = base64 parameter and parentid = the id of my custom object.

 

Is this the right path to take?

 

sfdcfoxsfdcfox

Depending on your programming language, the encoding might already be taken care of for you, but in most languages you'd have to do the encoding yourself, so you're on the right track. It should be a fairly trivial matter.