10 votes
Accepted

How to generate a PDF and have it download from a Lightning Web Component

You can use download.js to implement this functionality. The main idea is to convert the PDF into Base64 encoded String and pass it to the download method of download.js. Which will show the file ...
Saroj Bera's user avatar
  • 14.7k
9 votes
Accepted

System.StringException: Unrecognized base64 character: \

The content you are receiving is not Base64: it is Base64 inside JSON, which you are asking the server to provide to you. Base64 encoding uses the characters [A-Za-z0-9+/]. The backslash and quote ...
David Reed's user avatar
  • 92.8k
8 votes
Accepted

Issue while uploading file greater than 5MB

The actual limit is going to be closer to 4,500,000 bytes before encoding. Note that it has never been possible to send more than 12,000,000 bytes of data in a single transaction, and even then, only ...
sfdcfox's user avatar
  • 491k
7 votes
Accepted

How to store (or ignore) Base64 images in emails processed by email-to-case?

Following trigger parses case description for base64 images and creates attachments for case. Email-to-Case functionality stores email body in case description. Let's assume we have next html: <...
Ilya Lepesh's user avatar
  • 4,125
6 votes
Accepted

base64encode/decode issues with Blob.toString() method

Because PayloadBody2 and PayloadBody3 are null, you end up adding extra junk text to the end of the base64 string, which subsequently fails to decode. Make sure they're not null first: String part1 = ...
sfdcfox's user avatar
  • 491k
6 votes
Accepted

Parsing JSON in apex - getting error System.StringException: Unrecognized base64 character: {

Your simplification of the JSON here is detrimental, and is obscuring the issue. For purposes of providing an answer, I'll assume that there is some Base64 encoded string somewhere inside of the JSON ...
Derek F's user avatar
  • 61.6k
5 votes
Accepted

Integer Array to Base64 String

String.fromCharArray is going to create a UTF-8 encoded string, which will alter the bytes in the stream. For example, 242 will be encoded as two bytes instead of one. Any value outside 0-127 will be ...
sfdcfox's user avatar
  • 491k
5 votes
Accepted

Save base64 data as Attachment

Did you set the contentType as application/pdf? I tried this following code and it is working for me. String jsonStr = '<Base64 String>'; Attachment attach = new Attachment(); attach....
Saroj Bera's user avatar
  • 14.7k
5 votes

JWT, Cyrpto.Sign and EncodingUtil.base64Encode

As JWT is meant to be url-safe, the 62nd and 63rd characters used in Base64 encoding (+ and /, respectively) which are not url-safe must be replaced with characters that are url safe. + is mapped to -,...
Derek F's user avatar
  • 61.6k
5 votes
Accepted

How to call a web service with base85 encoded data?

Unfortunately for you, there's not much that can be done here aside from checking to see if someone else has already implemented a Base85Encode method (a cursory google reveals that nobody has done ...
Derek F's user avatar
  • 61.6k
5 votes

Displaying Images on Visualforce pages using Base64 Blob

Figured it out after debugging a bit more. Blob img; public Object getImg () { List<ContentVersion> bodyList = [SELECT VersionData FROM ContentVersion WHERE ContentDocumentId='insert your ...
Illusion's user avatar
  • 185
5 votes
Accepted

Is there a BASE64 Encoding Function using SQL in Automation Studio?

You can have 2 steps in your automation to solve this: 1- SQL Query to Pull data into a DE 2- SSJS Script to go through the Data extension and Update an "encodedEmail" field with the new encoded ...
Bechir's user avatar
  • 526
5 votes
Accepted

What is the difference and pro and cons uploading documents to Rest api Salesforce in binary format or base64

If you can upload in binary format, do so. If your source platform cannot use binary, then use base64. Base64-encoded data is approximately 33% larger, meaning longer upload times, more bandwidth used,...
sfdcfox's user avatar
  • 491k
4 votes

download base64 as PDF seting a name for it

If you change the way your component works rather than using a force:navigateToURL event and instead put your octet stream into an anchor tag, you can use the download attribute on the <a> tag ...
nbrown's user avatar
  • 4,013
4 votes
Accepted

CSV decode in Apex

You need to take data and base-64 decode it: String myFile = EncodingUtil.base64Decode(file.split(',')[1]).toString(); Alternatively, you could have decoded it in JavaScript and sent the string in ...
sfdcfox's user avatar
  • 491k
4 votes

CSV decode in Apex

Use: EncodingUtil.base64Decode(file).toString() Instead of: EncodingUtil.urlDecode(file, 'UTF-8') Encoding Util class Blob Class
gNerb's user avatar
  • 9,491
4 votes

EncodingUtil.base64Decode will throw exception on illegal input

You can take the "long way around" by first converting to hex, then converting to URL-encoded form, and then finally to UTF-8 via ISO-8859-1 decoding. // 'ááááá' in base64 in ISO-8859-1 Blob ...
sfdcfox's user avatar
  • 491k
4 votes

Generate and download PDF file from Base64 Encode String

I've solved the problem. Here is the change in client-side controller: let element = document.createElement('a'); element.setAttribute('href', 'data:application/pdf;base64,' + response); element....
Tran Tai's user avatar
3 votes
Accepted

Download ContentVersion Object as JPG using JSForce

Here is a sample JS fetch request I converted in Postman (this is pseudocode and probably wont work). I use the the following endpoint /services/data/v48.0/sobjects/Attachment/<ATTACHMENT_FILE_ID&...
Max Goldfarb's user avatar
3 votes

Hitting heap size limit while trying to convert attachment blob into base64 format

Converting to base64 increases the size by 33% (4/3). If this exceeds the heap size of 6MB, you'll get this error. This limits you to processing approximately 4,500,000 actual bytes. If you use Future/...
sfdcfox's user avatar
  • 491k
3 votes
Accepted

base64 as parameter from RestRequest non valid for deserialize

Can you try validating your base64 photo URL at https://base64.guru/tools/validator. maybe there is some issue with URl or undefined value. Sometimes you need to deserialize the JSON first, into a ...
Jaydeep Godara's user avatar
3 votes
Accepted

Weird "common.apex.runtime.impl.ExecutionException: Syntax error"|0x78b85a0a while doing a Callout

I was able to figure it out. As the hint of the last character was giving it turns out that I had checked by mistake the Allow Formulas in HTTP Body in the Named Credentials definition. So because I ...
ymiki's user avatar
  • 73
2 votes

Unrecognized base64 character: {

Encoding/Decoding is different from Serialization/Deserialization The JSON you have for fake response is malformed. If all you are getting from the response is Base64 encoded string, you don't need ...
karthikselva's user avatar
  • 2,466
2 votes

uploading files in contentVersion using lightning component

I suspect we can use the new fileUpload in Lightning. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_fileUpload.htm
Pat's user avatar
  • 181
2 votes
Accepted

Retrieving a standard base64 field from Lightning Component causes internal server error

I didn't find a way to directly return the base64 field as part of the ContentNote record. I ended up having to use the workaround in the question - omitting the base64 field from the query, and ...
Brian Mansfield's user avatar
2 votes
Accepted

Displaying user's profile picture dynamically in email template

Access to User.SmallPhotoURL or User.LargePhotoURL needs authentication. In your case this might be a issue. Instead use ChatterUsers class to get the photo URls. There is a variable called ...
Saroj Bera's user avatar
  • 14.7k
2 votes

Retrieving VersionData with standard REST API

The problem was jQuery ajax method. Files should not be treated as strings. I solved the problem by leaving jQuery's ajax as I did not succeed to request a response type. By switching to plain JS and ...
Petr Vav's user avatar
2 votes
Accepted

Attachment content is empty

This file looks like a legitimate PNG file fragment when saved and downloaded. Reading through the file, we see: tag length data Magic 8 iVBORw0KGgo= // PNG HEADER IHDR 13 Width = 1678, Height = ...
sfdcfox's user avatar
  • 491k
2 votes

How to change file properties(Created By, Modified By etc.) while sending file as base64 in API Callout?

The audit fields cannot be set. If you check the DriveItem resource, you'll see these properties are read-only. For example: Property Type Description ... ... ... createdBy identitySet Identity of ...
sfdcfox's user avatar
  • 491k
1 vote

JWT, Cyrpto.Sign and EncodingUtil.base64Encode

You can encode the signature using the below method : public String base64URLencode(Blob input){ String output = encodingUtil.base64Encode(input); output = output.replace('+', '-'); ...
vanessen's user avatar
  • 2,655

Only top scored, non community-wiki answers of a minimum length are eligible