Tuesday, 18 June 2013

Converting a Rich Text Area Field's Image for API Upload

Problem: Uploading Images Using the API

If records include rich text area fields containing images, you must convert the image to Base64 and supply that as the value in the relevant field. You can use a text editor to do this.

Solution

  1. Encode the desired image into Base64.
  2. Copy the entire Base64 image string to the clipboard.
  3. Copy the following text and paste it into a text editor:
    1<img alt="<image_Name>" src="data:image/<image_File_Extension>;base64, <base64_Image_String>"></img>
    • Replace <image_Name> with the file name of the image. Don’t include the file extension. For example: Headshot1
    • Replace <image_File_Extension> with the extension of the image file. Don’t include the dot. For example: jpg
    • Replace <base64_Image_String> with the string that you copied in Step 2.
  4. Copy the entire source text data and use it as the value in the relevant field of the API.
  5. Upload the data.

2 comments: