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
Bhu'1 salesforceBhu'1 salesforce 

base64 string to sfdc Image via webservice

Hi All,

I need to convert the base64 Json string which is passed from webservice as an input, here in sfdc i need to display the base64 string and display it as an image formate.

Please shut some light and let me know what are all the possible ways to achieve this and display it in sfdc custom object.

Thanks & Regards,
Bhuvan 
karthikeyan perumalkarthikeyan perumal
Hello,

String Base64string =webservicescall();
Blob afterblob = EncodingUtil.base64Decode(Base64string);

Document ImagDoc=new Document ();
ImagDoc.Body=afterblob ;
insert ImagDoc; 

in VF page :
<apex:image id="theImage" value="Inserted Image URL" width="500" height="500"/>
Show the image using apex tage 

Hope this will help you. 

Thanks
karthik

 
Bhu'1 salesforceBhu'1 salesforce
Thank you Perumal..! For your prompt reply.

But is there any option to display directly into the salesforce with out using reference Document object or Attachment object. If not, Please let me know how to trigger image stored in Attachment to display in parentid object as a profile_image.


Thanks & Regards,
Bhuvan
karthikeyan perumalkarthikeyan perumal
Hello
sorry, forget to add this code.you can display your blob content directly in to visualforce page. 
Create new visual force page.
 
<apex:image value="data:image;base64,{!base64stringname}" />

hope it will solve your issue. 
Mark it best ANSWER if it's works 

thanks
karthik
Bhu'1 salesforceBhu'1 salesforce
All All,

My requirement was to capture the base64 string, which is passed as a webservice parameter - that needs to be converted as an image in Rich Text area field in custom object in salesforce.
I need to achieve it without storing it in attachments, as i have some other invoices as attachments.
Is there any other possibilities to achieve it?
Looking forward for your replies...

Thnaks & Regards,
Bhuvan