Forum Academy Marketplace Showcase Pricing Features

File Saved to S3 - Remove Extra Arguments

Hi, maybe someone can help me with this.

I use an external service to generate a PDF file and then I retrieve the original PDF file URL via API and save it to S3. The problem is that the original URL contains some extra arguments after the file name that should be removed before saving to S3.

Here is an example of the URL currently saved to Bubble S3

https://s3.amazonaws.com/appforest_uf/f1612635654070x217160790976318500/Report_17_Mario_Brambilla.pdf%3Fresponse-content-disposition%3Dattachment%26X-Amz-Expires%3D3600%26X-Amz-Date%3D20210206T182053Z%26X-Amz-Algorithm%3DAWS4-HMAC-SHA256%26X-Amz-Credential%3DAKIAJ2ZTKW4HMOLK63IQ%2F20210206%2Feu-west-1%2Fs3%2Faws4_request%26X-Amz-SignedHeaders%3Dhost%26X-Amz-Signature%3D648f46bf6bc12900566e59b0deb560ec3c983e2dc69501240a4765b8b760ffde

While I would like to get only the following URL https://s3.amazonaws.com/appforest_uf/f1612635654070x217160790976318500/Report_17_Mario_Brambilla.pdf

Any help is very much appreciated. Thank you !

1 Like

Hello,

It looks like you are uploading files as private. Can you share a screenshot of the Generate a PDF action, please?

This is the screenshot of the backend workflow. When the Endpoint rpt_monkey is run, on step 1 action I call an API and I get the “document, download_url” info. This is the original URL with the extra parameters. Then, on step 2 I use the action …document_url:saved to S3. But the problem is that the extra parameters are part of the URL and I should be able to get rid of them.

The Amazon url parameters are always in a predictable order so you should be able to do a search for .pdf in your url that will give you a number of characters it’s found at. Then use :truncated to (that length+4) to chop the string off

Hi @richard10, I tried to implement your proposed solution but since the field where I save the PDF it is a “file” type it is not possible to do any truncate or search of any kind after the :saved to S3 action.

Just to better address the issue, one solution I can think of is to somehow remove the extra arguments from the original URL when saved to S3. But there should be also another option, like taking the file from original URL and save it with a custom name in Bubble.

Changing the original file name when saved to S3 should be a common option, but I really don’t know if there is a way of doing it. Anybody had this problem before ?

Hello,

Is it worth to use PDF monkey vs creating it in Select PDF or PDF conjured, etc. ?

@ryanck I will write down in another post about PSD Monkey but I can tell you that their service is fantastic. After a number of disappointing, frustrating and time consuming experiences with all the well known Bubble PDF plugin client-side, I decided to give a try to PDF Monkey and it works like a charm. I can pass complex query via API, generate PDF without slowing down users and create nice looking templates.

There is only this stupid thing with Bubble that is not capable to strip the additional parameter coming from the PDF Monkey url. This does not mean that the file is not saved to S3 but just that when users preview the file they have hard times to download it.

I have asked to Bubble support too, but no useful insights from them. Talked to PDF Monkey as well and from their point of view the additional info in the URL are just there because the file is private and has a download expiration time. They say that Bubble should be able to understand the file name and separate it from the other parameters. Of course Bubble says that this is not how it works the saved to S3 action. And I got stuck in the middle.

I ma certainly available to pay for the solution, but I have not received any offer so far.

Wow! Thanks for the explanation @stefanof.

I’ll take a deep look at PDF Monkey to see how to get it working and hopefully you’ll get a solution for the S3 issue.

Have a good day man :slight_smile:

Hello again,

Just wondering if you’re able to send the PDF via email after it’s generated like what you can do with select PDF and bubble.

Also, I´ve seen that they charge 0,09 €/PDF and SelectPDF gives you 2000 documents/month paying 19$. Just wondering if it´s worth the extra cost.

Thanks a lot.

Once the file in S3 you can send it via email. The issue is only about the filename (I guess).

About the extra cost, my app is for managing business travel expense and the PDF is needed for accounting purposes. There is a free tier up to 300 PDF a month that I can use for my free users. Then I charge € 2.00 per expense report and I think that $0.09 per PDF is a reasonable cost that I can take. Of course if someone will ever make a Bubble PDF plugin working server side I will consider to switch.

Ah ok. I´ve spoken to them this morning. They seem to have a robust service and new prices coming up.

Thanks a lot for all the information @stefanof .

I think you can try uploading files using an API endpoint.


You will need to use the API connector:

Editor:

Hi @lottemint.md, thank you for your suggestion. I took a look at what you are proposing and it is interesting what you have done in the test example. Maybe it’s me that I don’t understand, but the thing is that I need Bubble “save to S3” action point to the original URL (with all the extra info, since the file in PDF Monkey is private and the link expires after 30 sec) but then save the file with a custom name. This name can be extracted from the URL, can be taken from the API or I can create a name in Bubble. But what is needed is kind of “saved to S3” in two steps: first step tells Bubble the URL of the file to be saved and second step tells Bubble the name to give to that file. Any idea how to achieve this ? Many thanks.

@stefanof how did it go, did you get any luck with it?

I found this old post Problem with Saved S3 in the forum that’s about the same issue. Maybe @NigelG or @habekost can help (sorry guys to bother you :slight_smile:)

1 Like

You should be able to do this with Regex

In your action create a new COY, your second variable, the url, you should be able to do :extract with regex

“%.*$” should mean, “get rid of everything after the % sign”

Unless I missed something in the rest of the issue/thread, then you’ve got a proper URL without parameters you can put somewhere and use it,

Thank, @richard10 . Can you please make an example for me ? Because as far a I know Bubble does not allow you to put any other action after the “saved to S3”. And if you change the URL before the file can not be downloaded (since the extra arguments are for privacy and expiration).

OK
now I understand the issue, so ideally you want to
download_the.file%with%all%its%rubbish
then use that as a result of step 2
to
use_the.file:saved to s3
Right?

Yes, I need that Bubble let me point the original URL (with all the rubbish :wink:) in order to download the file and then give me the option to change the file name before it is saved to S3.