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
MeenakshmiMeenakshmi 

Storing images in SF in the form of Binary Data(Bytes)

Hi All,
I want to store image in the form of binary data in salesforce.
When user will try to attach an image, image will be converted to binary data and will be stores as bytes in SF database. 
When user would like to see the image, binary data will be converted to image and will be shown.
Can anyone help.

sfdcfoxsfdcfox

To store the image, use an <apex:inputFile> element; the uploaded file will be assigned to a value in your controller as a BLOB (Binary Large OBject). From there, you can store it as a Document, Attachment, or Content.

 

To view the image on the screen, just provide a link to the content (e.g. "/servlet/servlet.FileDownload?file={!file.id}").