Forum Academy Marketplace Showcase Pricing Features

Uploading Base64 File to Database

I’m trying to upload a base64 encoded file to the database. I’ve tried a bunch of different methods and can’t get it to work.

Goal:
I have a page for users to e-sign a PDF agreement. When they e-sign it, I have JavaScript that overlays some text over the original PDF saying that they signed it at this date. I want to save that file to the user’s account in a field of the type “file”. (We’ll call that field “agreement”)

What I’m doing now:
My JavaScript sends a base46 encoded pdf to a JavaScript to Bubble element as a string of text. I’m then able to set the current user’s “agreement” to that JavaScript to Bubble’s value. This is working, but causes several problems:

  1. The file is still base64 encoded, so it takes more space.
  2. Also since it’s base64 encoded, there are some issues viewing the file later. Firefox will show the pdf, but Chrome has trouble loading it.

What I’ve tried so far:
Plugins- I’ve tried multiple file uploaders, but haven’t found one that lets you upload through a workflow (even by changing the uploader element from the workflow).

I tried Zeroqode’s Base64 File Uploader & Downloader which looks promising, but I can’t find any documentation on it, and whenever I try to use it it makes my JavaScript to Bubble element throws a DNS error.

APIs- I tried using the undocumented website-home-url/fileupload hack outlined here but I get an internal server error saying there’s a temporary bug.

I also tried using the regular data api and adding the file that way, but I think that left the file in base64 format. (I’ve tried so many things at this point I’m starting forget why each one didn’t work.

Any advice on how to handle this? I’m willing to use a plugin, modify my JavaScript, use API’s or anything else that will work! I just can’t seem to figure this one out.

This action:

“Write from Base 64” save any base 64 encode bytes to Bubble’s Amazon S3. Returns the created file.

1 Like

Thank you for this! I tried it briefly yesterday, but wasn’t able to get it to work yet. It looks like it’s working right, but when I go to the url of the saved file, it’s just blank. I’ll dig a little deeper soon and see if I can figure out specifically what’s going wrong.

1 Like

Maybe filesize is too large or it’s timing out. Serverside actions have some limitations

Yeah, that was going to be one of my first things to check.