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 )
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 ) in order to download the file and then give me the option to change the file name before it is saved to S3.
Can you make a really simple GET API call like this
To get your PDF with all its %rubbish%
Then you have a file in an action you can probably use :save to s3 on
I am fighting with s3 myself this week. I’ve managed to figure out most of the API stuff but it’s a pain in the behind.
Take a look at my first posts here and you will see that I am getting all the info from an API. Again, the problem is not getting the file, saving the file or re-naming the file. The problem is that when the end user will try to download the file (in my case is a PDF) the file name (stored in S3) will contain all the rubbish. Of course if end user is smart enough to separate the rubbish, there is no issue. The file will be saved locally as a normal PDF. But this is not what you want to do (think about on mobile).
When you try to download the file only using the filename itself with no additional parameters after the filename, is access denied?
Yes, you get an error from the external URL. That’s what the rubbish does … controls if you have authorization and if URL is not already expired (30 sec.)
OK that “rubbish” is an amazon pre-signed URL I think it expires in an hour (3600 sec in the signature parameters). the signature contains details of the request so you can’t manipulate that in any useful way. If you want to be able to download this file, from S3, with the bucket security in place, then the only way to obtain a file is with a URL in that format.
We have our own amazon bucket and I am currently working on the uploads and downloads to and from our own bucket. In our bucket we have a folder that has global read only access. In the same situation I would:
Get the file using the simple API call I showed above from the amazon presigned URL
hold in memory in a step in bubble
use an amazon post into our own bucket, where I can set the file name however I want and where there are no credentials to download it later
And then set up some housekeeping api actions for later to delete it when it expires
BUt this is genuinely not trivial
One of the other cloud storage providers might have a much simpler API than amazon for writing your data to a folder there and no URL parameters when downloading. Either way the filoe is in the bubble bucket in S3 and you can only get stuff out if it with those parameters, as far as I’m aware.
Yes, you can set any name.
Using the method suggested, I’ve uploaded and renamed your file to test.pdf:
I have the same problem. The external service we use requires parameter based retrieval of a file using an id:
GET https://external-service/v1/file/[fileId]/content
When using the file option on the API Connector all files retrieved are saved in S3 with the name “content”. This name is unsuitable for our customers and users for several reasons.
We have the actual filename for each file id, but we can’t figure out how to tell Bubble the name to use when saving the file to S3.
@lottemint.md It sounds like your recommendation is:
- Expose a new public endpoint
- Have the app send it to itself over the network encoding and decoding to base64 as necessary (using a Bearer token to make sure the app knows that the requests are coming from itself)
While I can imagine that this might work, it’s rather hard for me to imagine this would be the recommended way for choosing a file name or for renaming an existing file for that matter. I’m hopeful there’s a more pragmatic solution that I’ve overlooked in the manual or reference or that can be found here in these forums.
I would be very grateful for any alternative suggestions!
I was just checking for any progress in the threat, but it seems that there are no substantial news. Maybe @eve can help us. I repeat the question here: how can we change a file name before it is saved to S3 ? The full issue is explained in my first post in this thread. Thanks
It looks like, Bubble team added a new feature:
Thanks @lottemint.md for sharing the news
But the biggest thank you goes to @emmanuel who listened to my requests and solved the problem. . Grazie mille !
Hello @stefanof ,
You still working with PDF Monkey? Do you mind pointing into the right direction?
Thanks a lot man
Hi @ryanck ,
yes I am still using PDF Monkey (but now they require a paid plan). After opening you account, you need to build your PDF report using the tools provided by them. Some research is needed, it took me some time but not too difficult to learn.
This is a screen shot of the html section of an expense report I built in PDF Monkey.
And this is the data section (basically the JSON structure that you will feed from Bubble).
Once you are done, grab your API key and make an API call in Bubble using the API Connector.
Then I have created a backend workflow that it’s triggered every time a user clicks on a PRINT button. In this WF I created and saved in the Bubble DB a filed that contains the JSON with all the data to send to PDF Monkey. Use the “formatted as text” expression to manage nested data.
After that, just call the API and send data to PDF Monkey, where the PDF is build and saved.
That’s about it ! The only thing that I was not able to do was to use the PDF Monkey web hooks in order to retrieve the PDF file once created. I used a workaround and schedule another backend workflow to check when the PDF is ready and save it to Bubble database.
The PDF file is now available to be viewed or download by end users.
I hope this may help
Nice explanation @stefanof
How do you handle the dynamic data? I´m trying to use it for generation of our user´s invoices and each invoice can have multiple line items such as 5 or 40 line items.
Also, still cannot retrieve the PDF file? That´s odd. Is it because Bubble´s limitations?
Thanks a lot man.
@ryanck maybe you should move this discussion in a separate thread. Anyway, dynamic data come with the thing that you are sending to the backend workflow. In your case it will be a single invoice, I guess. Available data largely depends on your data structure. For what concerns the PDF file, as I said, I ended up scheduling calls to PDF Monkey to check when the file is ready and then I grab it and save it.
Should you need more help, PM me. Thanks