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
sujin h ssujin h s 

How to convert base64(blob) into image and saving it in apex?

Hi all,

My requirement: I have to select some part(for eg: a table in my component) of my component and save it as image.

I'm able to retrive the pixel data(base64 or blob) using Canvas & converting it into image(jpg) in apex and sending it as mail using
efa.contenttype='image/jpg';
            Blob body = Encodingutil.base64Decode(data.substring(data.indexOf(',') + 1));

I'm successfully able to do it.

But I want to convert it as image/jpg and saving it local file OR to salesforce folders so that i can download the image.

Can anyone help with code?

Thanks! in advance
Vishwajeet kumarVishwajeet kumar
Hi,
Assuming you have tried to use same Blob body in creating Attachment/Document and saving it in salesforce.

Thanks.