+ Start a Discussion
Vaibhav ShettiVaibhav Shetti 

How to convert a blob or byte array to base64 encoded string?

I know -
Converts a Blob to an unencoded String representing its normal form.

But what if I want the blob to be converted to base64 encoded string? Is there way for this?
David Zhu 🔥David Zhu 🔥
I am also confused of the description of basd64Encode method. But I think base64Encode actually convert to Based64 encoded string. you can verifiy by use Base64Encode the, use Based64Decode to get the original string.
blob x = blob.valueof('this is a test');

string s = EncodingUtil.base64Encode(x);

system.debug('s:' + s);

blob y = EncodingUtil.base64Decode(s);

system.debug('y:' + y.toString());