You need to sign in to do that
Don't have an account?
merthen
decode base64 in apex class
I am trying to pull the body of a "Document" into my apex class from which I would like to extract name/value pairs (like reading a properties file).
I find that the body is base64 encoded.
How can I decode that in my apex class?
Works for me!
Thanks!
I actually didn't even have to use the "EncodingUtil" class...just did a blob.toString()
Here is my now working code. Its not very elegant but it works! (poor man's properties file)
Document doc = [Select d.Body From Document d where d.Name='Solution Areas Mappings'];
Blob bodyBlob = doc.Body;
String bodyStr = bodyBlob.toString();
List<String> parts= new List<String>();
parts = bodyStr.split('\n',-2);
System.debug('---------'+parts[0].substring(parts[0].indexOf('=')+1,parts[0].length())+'-------');
All Answers
Works for me!
Thanks!
I actually didn't even have to use the "EncodingUtil" class...just did a blob.toString()
Here is my now working code. Its not very elegant but it works! (poor man's properties file)
Document doc = [Select d.Body From Document d where d.Name='Solution Areas Mappings'];
Blob bodyBlob = doc.Body;
String bodyStr = bodyBlob.toString();
List<String> parts= new List<String>();
parts = bodyStr.split('\n',-2);
System.debug('---------'+parts[0].substring(parts[0].indexOf('=')+1,parts[0].length())+'-------');
Hi,
Although this is old maybe you can give me an answer:
I'm trying to get some attachments are base64 with apex I always jump when opening decryption errors or open encrypted.
My code is:
Thanks