Base64 to File Converter – Convert Base64 Strings into Salesforce Files

Recently I created a Flow Component that extacts text from an image called Flow Document Scanner that Salesforce API used for the text extraction also outputs a Base64 string of the image file after extracting the text and I wanted a way to store that image as a file in Salesforce so I created the Base64 to File Converter Invocable action that takes that Base64 string and creates a ContentVersion and relates to a record. After some feedback I heard that there was a need for this outside of my use case so I am releasing it on Unofficialsf as a stand alone Invocable Action. Let’s take a look at another use case and how the action is used.

Use Case Overview: Uploading User-Generated Content

Imagine a scenario where your organization collects user-generated content—such as images or documents—through a web form. This content, once submitted it is stored in a raw Base64 format in a database, but you have a requirement now that the images also need to be stored in Salesforce for future access and management. However, the challenge lies in converting this content into a format that Salesforce can handle effectively. This is where Base64 to File Converter comes into play.

The Solution

In our scenario we already have a developer who has an integration setup that is creating a platform event in Salesforce when a file is uploaded into our companies database. So to help keep things simple we are going to create a platform event triggered flow to handle the Base64 conversion and file relationship.

Step-by-Step Implementation

1. Create a Platform Event triggered flow. Our flow is going to Get an Account record with a matching external Id then it will convert our Base64 String to a File and attach it to the Account. Then to save us some work later it is going to create a Content Delivery record based on the ContentVersion output by the Base64 to File Converter action.

2. Let’s take a deeper look at how we configure Base64 To File Converter. The first thing I need to enter is the file name including the file extension i.e. myfile.jpg in our use case we are getting that from our Platform Event. Next I need to enter my Base64 String and finally the Related Record Id.

3. Base64 to File Converter outputs the ContentVersionId of the file that gets created so if I need to do other things with the file like in our example create a ContentDistribution record we can do that without having to go find the file we just created.

Finally

As an flownatic I now have a quick and easy way to convert Base64 to files without having to code it all myself I just drop it into a flow and I am done.

Attributes

AttributeTypeNotes
INPUT
File Name

Base64 Encoded File Content

Related Record Id
String

String

String
The name of your file with the appropriate extension i.e. myfile.jpg

Base64 String

Id of the Record you want to relate the file to
OUTPUT
Content Version IdStringId of the created Content Version

Installation

Production or Developer Version 1.0.0

Sandbox Version 1.0.0


Release Notes

1/13/2025 – Josh Dayment – v1.0.0
Initial Release


View Source

Source Code