Forum Academy Marketplace Showcase Pricing Features

Convert PDF to Base64

Hi all

Looking for a quick and simple way to convert PDF files to BASE64 so they can be sent via email.

Using both the Bubble.io single file and multi file uploader. Files are private.

Thanks
S

Hi @klobassimon,

In most situation you want files to be private since that prevents unauthorized users/people from accessing them. However, the single and multi file uploader only make files private if you configure them to do that. By default making files private is not active and if it is, simply deactivate it by unmarking “Make this file private”:

image

Bubble’s standard send email action has the option to attach a file (see image below), you dont need to do anything with base64 encoding.

But if you really need it, Bubble has the option to encode in Base64 by default:

Hope this answers your questions. If not, do you mind to explain a bit more what you are trying to achieve?

Best,

Gerbert
MOG Consultancy / MVP Design

I’m not sure what the workflow is…

But in some cases my plug-in Better Uploader might be of use to you. When you give it a file, it exposes the file (of any type) as a base 64 value (a Data URI) in the Raw Data exposed state.

Although, if what you’re asking is how to convert pdf to data uri on the fly the other answer might be helpful

Cheers

HI @gerbertdelangen

Thanks for all the info. We’re looking to send via Sendgrid (using CoPilot plugin).

We have got the private files sorted, and we are storing the base64 code in the DB at the time of upload.

Maybe it is simpler than I think and we just need to somehow combine the file URL and teh base64 code in the file field when sending the email. Is this correct or is there something that needs to happen at the point of uploading the file.

S

Hi @klobassimon,

It seems you are doing everything right. It is probably just a step that is missing or wrong config somewhere. Here is an example, it should clarify things:

  1. The settings for the file uploader:

  1. To be able to access the file in the workflow in the datatype temp I have added a field file (type file):

  1. After uploading the file, the file (or link) is added to a row in table temp:

  1. The Copilot Send email action is configured like this:

  1. The resulting email:

This should work, if not, just add a couple of screenshots of your configuration and workflow and we should be able to find out what is wrong.

Hi Gerbert,
Thanks, my email is still coming across unformatted.

I have attached the file as ‘file - encoded in base64’ AND also I have first converted the file to base64 using a plugin and have tried to attach that data as the file. Both to the same result.

See attached screenshot of the workflow and the receipt email.
Any help appreciated.

S

That is unfortunate. Then we need to rule out some things. Often times it is the privacy rules that cause the issue (actually the improper use of privacy rules :slight_smile: ). Do you mind to turn of the option “Make file private” in the uploader element, upload a new file (important) and try to attach it to the email like I showed you? Maybe even create a new workflow for the time being (to rule out some under the hood Bubble bug).

Hi Gerbet,
Thanks for the continued assistance here.
I’ve turned off private files and re uploaded a new doc and re sent - same issue unfortunately.
Hmm where to now!?
S


Hi K, that is strange. Did you recreate the workflow in order to be sure it is not a bug that is causing the issue.

Anyway, if you are OK with it, you can set your app to “everyone can view” so that other can have a look at it (Settings - General - Define who can see and modify the app). Do you mind to do that and send the link to the editor (not the public)? You can PM it if you don’t like others to have a look in “the kitchen”?

The link will look something like this: https://bubble.io/page?type=page&name=index&id=“your-app-id”.