Now, here’s something I’m facing about this Base64 / file encoding:
I have an API that provides me a file output as “octet/stream”. There I can have multiple types of files: PDFs, images, Autocad projects, binary files, and so on.
There’s nothing on the headers on that API mentioning the file type nor the file name. It just returns me a “body” with the base64 content.
When I initialize the API call to this service, I set on my header:
Content-Type = application/json
Accept = application/octet/stream
I also set the “Data Type” on Bubble as “File”, because I want to save that stream as a file in Bubble and I need to consume that file in a Bubble form. In fact, my goal here is to download a PDF, and with the file, do an OCR scanning to retrieve the plain text of this PDF.
In this example, I have a PDF file to download/upload/save in Bubble.
Now, what’s happening is:
- The API is successfully initialized
1.1 It creates a file on S3 (File Manager) named: api_initialize_file, of type “application/octet-stream”, the “User ID” has a number in there (even though I’m not using any authentication).
1.2 If I click “view”, it downloads the file “api_initialize_file”
1.3 I add the “.pdf” extension in that file and the file open without any issue. This means the PDF file is being transferred
I’ve added a button to trigger the file upload to Bubble, and simply running the API call to the service creates a similar file, but now named “download”.
I created a “thing” to store the link to this S3 file, and I added a second step to create a new thing.
I have a field as “File” type and another as “Text”.
I could successfully have both file and text populated, but again, when I click in the file for download, it downloads the file without the extension. I tried to add the extension, appending the file name, but it seems the file is linked with the S3 origin, so no much success.
My question is:
Is there a way for me to change the file type from “octet-stream” to “application/pdf” on S3 “file manager”?
I had an epiphany to change my output from File to Text, then the PDF content comes in. Not the Base64. Is that a way for me on the fly to save this file as S3 and as a Thing?
I tried the other methods to send a file to Bubble, which worked - like sending a PDF, but I explicitly set the “content-type” to “application/pdf”. However, none worked with that specific API I need to consume.
My goal is to consume that PDF that comes from the API as a step for an OCR reader, so it requires a “link” or a “thing”. I didn’t see any way for them to access a file directly without being on a thing.
Any help is much appreciated! I’m brand new on Bubble and I’m loving it!