I'm getting a base64 String pdfContent from a callout response which I'm trying to save as a attachment of a record. I tried to save it after decoding it with
EncodingUtil.base64Decode('base64String');
- Didn't work
Tried to simply store it as Blob with
Blob.valueOf('base64String');
- Didn't work
The Blob is getting saved as attachment But When I try to view it, It throws an Error
"Failed to load Pdf Document"
How can I make it view-able?
Here's the apex logic of storing the attachment.
String base64String = 'some base64 String';
Attachment atc = new Attachment();
atc.Name = 'Test.pdf';
atc.ContentType = 'application/pdf';
//atc.Body = Blob.valueOf(base64String);
//atc.Body = EncodingUtil.base64Decode(base64String);
//atc.ParentId = 'a0041XXXXXXXXXX';
insert atc;