简体   繁体   中英

AWS s3 redirect to another s3 bucket

Built an html page, when you visit it, depending on pre defined parameters in the javascript code, you will be served an auto download. This is for a company's backend.

This worked fine when the files were all hosted on the same server, but since I migrated to AWS s3 and have the files on one bucket and the page on another, it now wants to visit and redirect where the file is, instead of downloading the file while staying on the page.

Checking the file for download the header type is application oclet/stream on AWS s3 mime-type. When visiting the url directly it downloads the file fine.

if(theParamsMatch){
document.location.href=https://s3.amazonaws.com/theNameOfSite/downloads/yourDownload.html;

  }

If you're storing your files on Amazon S3 then any settings on your web server are ignored. It sounds like you want to adjust the S3 settings for that file in the S3 console in order to fix your problem.

  1. In your S3 Bucket find the file you wish to work with and click it.
  2. Click on the "Properties" tab
  3. Click on the box that says "Metadata"
  4. Click on the circle to the left of the Content-Type and then click "Add Metadata"
  5. Set the "Key" to "Content-Disposition" and set the value to "attachment" and hit save.

This will force it to be downloaded instead of displayed in your browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM