Hot answers tagged

8 votes
Accepted

Save attachment with Remote Objects

Based on the error message you get when you attempt to retrieve the body of an attachment: Visualforce Remoting Exception: No serializer found for class common.udd.object.EncryptableFfxBlobField$...
user avatar
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 ...
user avatar
  • 439k
7 votes
Accepted

Salesforce isn't handling Base64 Encoded attachments uploaded via Rest API

Based on my research, I have concluded that at the time of this writing (using REST API v32), Salesforce does not decode uploaded base64 encoded data for Attachments. This is a bit confusing, since ...
user avatar
  • 1,039
7 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 ...
user avatar
  • 87.4k
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: <...
user avatar
  • 4,087
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 = ...
user avatar
  • 439k
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 ...
user avatar
  • 439k
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....
user avatar
  • 13.2k
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 ...
user avatar
  • 49.5k
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 ...
user avatar
  • 175
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 ...
user avatar
  • 506
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 ...
user avatar
  • 49.5k
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 ...
user avatar
  • 439k
4 votes

CSV decode in Apex

Use: EncodingUtil.base64Decode(file).toString() Instead of: EncodingUtil.urlDecode(file, 'UTF-8') Encoding Util class Blob Class
user avatar
  • 9,121
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 ...
user avatar
  • 3,634
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 ...
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&...
user avatar
3 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,...
user avatar
  • 439k
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 ...
user avatar
3 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 ...
user avatar
  • 439k
2 votes
Accepted

Generate another ID by encoding the Salesforce ID

As long as your only concern is generating a unique ID that can safely be included in a URL querystring, you could just escape ("urlEncode") the output of your current code: EncodingUtil.urlEncode(...
user avatar
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
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 ...
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 ...
user avatar
  • 13.2k
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 ...
user avatar
  • 2,406
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 ...
user avatar
2 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 -,...
user avatar
  • 49.5k
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/...
user avatar
  • 439k
1 vote

Insert base64 string as attachment using apex dataloader

You can use Data Loader to bulk upload documents and links into libraries in Salesforce CRM Content. Before uploading documents or links, note the following. If you intend to upload via the Bulk ...
user avatar
  • 3,273
1 vote
Accepted

HttpRequest Converting > to?

.replaceAll('=','%3D') should instead be EncodingUtil.urlEncode(... ,'utf-8'). This will make sure that all characters are properly encoded.
user avatar
  • 439k

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