Download File from S3 bucket

Does anyone know how to download files from an S3 bucket? I am trying to mimic the file upload server action:

This returns a URL that looks like a path to the file download but when I go to it in my browser, nothing gets downloaded. I am hoping that when this server action is executed, the user gets the S3 file downloaded. Please let me know if this is possible!

bump

If your files are public then you can link directly to them, for private files you need to use the signed download url. The server connect action returns indeed an url, it is a temporary link that can be used to download the file, it can only be used within a certain timeframe. You could for example use the download component to download the file automatically. On the load event of the server action trigger the download method on the download component with the returned url.

Thanks for the reply!

Does the server download take remote URLs? From the Wappler tutorial, it only seemed like it was local paths. When I tried it with the returned AWS URL I got:

path.toSystemPath: Invalid path "(the path)"

No, you need a client-side download. If you want to do it on the server then you need to download the file to the server first and then send it further to the client.

How do you download the file on the server in Wappler?

Hi Brad,

I made the following:

A button who takes the value and on click it pass to the signed download server connect (I add a variable in GET, which get the full key name, like: “/test/logo.jpg”)

Schermata 2020-11-02 alle 19.43.49

Schermata 2020-11-02 alle 19.44.19

then “Success” about download server connect, I select Go To from Browser component and as URL I put the signed URL.

Hi @patrick and @Teodor,
could you give a more detailed instruction on how to download from S3 with the download component (not public available file)?
I have a dynamic generated repeat with several documents. I now want to download the file on button click. I want to send the document id to my Server Action to get the signed URL.
This is how I have set up my Server Action:

The Server Action works but I can’t get the logic on how to use it in App Connect. Did I miss the documentation on how to do this?

I have an anchor button but can’t figure out what to do next? Do I need a flow for this?

Hi @updates,
could you make some screenshots of your App Connect side?

Hi, as I will be in office tomorrow morning will send it to you

1 Like

Thanks a lot!

Hello, sorry for late reply…

here the workflow to download a file from S3:

Here you see the record in the table with the button to download the file.

on click on the button, I set a variable containing the name of the file

and then I load the S3 sign download component:

here is how the S3 sign download component is configured

Then, I go to AppConnect, I select the server connect:

On DYNAMIC EVENTS I select “Success” and here magic happens…

I select browser component “Go To”,

On the URL’s dynamic data picker I select the signed URL returned by the Server Connect previously called:

You will get it…

The process works like that:

Clicking on the button you get the name of the file andyou pass it to the S3 Signed Download component, who generate the download signed address.

On “success” of the server connect, you load the browser component to “go to” the signed address…

Hope it is clear, in case write me

PS., sorry I should say “API” now… instead of Server Connect…

1 Like

Thank you for your detailed explanation. :+1:

Hi @patrick,

could you explain how to download from a S3 bucket with the download component? I could not find out how to do this. The way @updates shows with the browser component works but I would prefer using the download component.

I have only PDF documents to download and would like them to download directly instead of opening in the browser.

1 Like

@George Thank you for assigning @Teodor

following…

@baub - in case you didn’t realise, you can click on the ‘Tracking’ button to switch on notifications without needing to actually post.

ah cool. hadn’t noticed that before. Thanks!

1 Like

Hi @Teodor
Did you already have the time to make some screenshots on how to download a file from s3 with the download component like @patrick mentioned in the post above?