Forum Academy Marketplace Showcase Pricing Features

Saving base64 to pdf file

Hey Bubble Crew,

I want to save a pdf as a file in the bubble database rather than the base64 response I get from an API connector so I can then attach to an email and send. I don’t want to use a paid plugin as it seems something really simply achieved - just a bit elusive to me right now.

The following javascript works perfectly in the browser downloading the pdf file returned from the API call but I just don’t know how to achieve this in the backend?

Also, less important to me - is there a way to download a base64 file if it is stored as text in the database?

THIS IS JAVASCRIPT CODE THAT WORKS IN THE BROWSER - ALLOWING ME TO DOWNLOAD THE PDF FROM A BASE64 RESPONSE

let a = document.createElement(“a”);
let data64=“Result of step 1 (PDF Generator - p…)'s response”;
a.href = “data:application/octet-stream;base64,” + data64;
a.download = ‘filename.pdf’;
a.click();
console.log(a);

any help greatly appreciated.

Hey Morgan,

The “Bubble Back End Utilities” plugin has an action “Write from Base 64”, it is supposed to save any base 64 encoded bytes to Bubble’s Amazon S3 and return the created file. Maybe you can use that one.

If the solution above does not work for you, I just built something similar using n8n.io, an open source alternative to Integromat/ Zapier etc…

Let me know if you need some info.

Thanks for your response. I’ll check out that plugin. n8n looks interesting too - for lots of things, how do you find it compared to zapier and integromat / parabola etc?

No problem. N8N is less polished than Zapier and has less integrations (but it’s easy set up API’s). Integromat and Parabola i don’t have experience with. The pricing n8n offers is better.

You can use the open source version which you’ll have to install, host and maintain yourself or just use the cloud version.

Using N8N is a joy, it’s easy to build and debug. Using custom code is also easy.