Download File from S3 bucket

Marcel, what exactly the issue is here? I really don’t understand what issues you are having exactly?
Isn’t @updates explanation already doing what you need?

I’m referring to:

@updates explains it using the browser component. On click the PDF-File opens in the browser. I want to download it directly without opening the file.

  1. Add the download component on the page.

  2. Add your server action which runs the signed download on the page. Set it to No Auto Load

    • Use the dynamic events of the server action, select on done > download component > Download.
    • Add the path returned by your server action to the download path, like serverconnect1.data.signDownloadUrl1 (replace names to match your server action)
  3. Run the server action on a button click.

1 Like

Thank you @Teodor

Using the download component works! I still have the problem that the file is opened in the Browser instead of downloading it directly. Any ideas?
Can this have to do with the following errors I get in the developer tools?

I can’t find where to set cors on ionos.

One more thing:

It would be great to select a dynamic source for the download path:

image

Well check the documentation or contact the provider you are using.

1 Like

I contacted the the provider…and hope they have a solution.

It would be great to have a dynamic picker :slight_smile:

Hi @Teodor
I got the following link from IONOS to set CORS

I configured it like described but still get a CORS Error. Any other ideas what I could do?

Well it seems you have not properly set it up … i can’t really help you with your hosting config :slight_smile:

Well, that is my problem. I set it up just like on the link. I don’t get any errors on setting CORS with s3cmd, that’s why I was asking. All commands with s3cmd work. I wrote another email to the support team. Let’s see what they say.

Another thing I saw in the Warning section is the following:

Is this something to worry about?

@patrick can help with this warning message.

1 Like

The warning is not something to worry about, the sync method will be deprecated in the future but it will take years until it will be actual removed. Until then it will keep working.

The warning comes from a peace of code that is used to detect if cors is supported, we can then use the XMLHttpRequest for the download and can keep track of the progress. If no cors is supported the download will be the normal browser download and we can’t track progress of it.

@patrick thank you for your explanation. Could this be the reason that my download is opened in the browser instead of directly saving it to the downloads folder as long I didn’t get my CORS problem solved?

EDIT:
After a lot of emails and nearly 2 hours of screen sharing with IONOS support (which is great by the way!) I decided to create an account with aws to test s3 download with them (I should have done that earlier :slight_smile: ).

I get the exact same errors. That means it must be another problem I have. CORS is correctly set on the aws side. My .htaccess file also has the correct entry (Header set Access-Control-Allow-Origin “*”).

I set the download exactly like you described in the above post. Is it possible that the component does not work with private buckets?

For clarification for those who read this post:

  • I have a file in a private bucket
  • I am trying to download it with the above description within a content page (Post No. 22)
  • It does open the file in a new tab instead of downloading it directly
  • It shows the errors (Post No. 27) on my website (php)

I created a test page for better understanding the problem.

https://www.***.de (EDIT: test page not available anymore)

EDIT:
Could someone in the community test this, if the error is only on my side or if it is an issue with the Download Component? Thank You! I already tested it on 3 different websites with NodeJS and PHP. Same error everywhere.

Could you check if it is a bug or a problem on my side? As I wrote in my post above I also have the errors with aws. Thank you!

EDIT:
I‘m really sorry, but I would like to know if it is a problem on my side. Did someone got the Download Component with S3 working? Any hints what I could test? Do you need some screenshots of my configuration? @Teodor @George

EDIT2:
I’m getting a little further.

I could solve the CORS issue by adding “HEAD” to the CORS rule in AWS.

Direct Download still does not work.

I still get the following error:

I tested the test page and also do get the 403 status on the head request, but it also downloaded the file. The file was testfile.pdf with the content Testfile for S3 Download in it. It didn’t seem to use the xhr for download, it seems that it used the backup download strategy.

1 Like

Thank you for testing it. That’s the same I get. Any idea to solve this? Is there something you could change in the Download Component to make it work with S3?

@patrick added a Download File Server Action for S3 in 3.7.5