9
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 ...
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 ...
8
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 ...
6
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:
<...
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 = ...
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 ...
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....
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 ...
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 -,...
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 ...
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 ...
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,...
5
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 ...
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 ...
4
votes
CSV decode in Apex
Use:
EncodingUtil.base64Decode(file).toString()
Instead of:
EncodingUtil.urlDecode(file, 'UTF-8')
Encoding Util class
Blob Class
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 ...
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 ...
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....
3
votes
Accepted
Inserting a PDF Record as attachment Maximum view state size limit (135KB) exceeded
Since you are storing the Blob value of the PDF in the class variable b, the entire Blob is considered part of the Visualforce view state, so the page can't be rendered.
One option is to only use ...
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&...
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 ...
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 ...
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
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 ...
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 ...
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 ...
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 ...
2
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/...
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 = ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
base64 × 70apex × 26
attachment × 10
rest-api × 9
pdf × 8
files × 7
blob × 7
contentversion × 6
visualforce × 5
lightning-web-components × 5
marketing-cloud × 4
lightning-aura-components × 4
javascript × 4
httprequest × 4
crypto × 4
encodingutil × 4
ampscript × 3
images × 3
document × 3
trigger × 2
unit-test × 2
email × 2
integration × 2
json × 2
callout × 2