简体   繁体   English

AWS s3 重定向到另一个 s3 存储桶

[英]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.构建了一个 html 页面,当您访问它时,根据 javascript 代码中的预定义参数,您将获得自动下载。 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.当文件都托管在同一台服务器上时,这工作正常,但由于我迁移到 AWS s3 并将文件放在一个存储桶上,页面放在另一个存储桶上,它现在想要访问并重定向文件所在的位置,而不是下载文件,同时停留在页面上。

Checking the file for download the header type is application oclet/stream on AWS s3 mime-type.检查文件以下载 header 类型是 AWS s3 mime 类型上的application oclet/stream When visiting the url directly it downloads the file fine.直接访问 url 时,它可以正常下载文件。

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.如果您将文件存储在 Amazon S3 上,则 web 服务器上的任何设置都将被忽略。 It sounds like you want to adjust the S3 settings for that file in the S3 console in order to fix your problem.听起来您想在 S3 控制台中调整该文件的 S3 设置以解决您的问题。

  1. In your S3 Bucket find the file you wish to work with and click it.在您的 S3 存储桶中找到您要使用的文件并单击它。
  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"单击 Content-Type 左侧的圆圈,然后单击“添加元数据”
  5. Set the "Key" to "Content-Disposition" and set the value to "attachment" and hit save.将“Key”设置为“Content-Disposition”并将值设置为“attachment”并点击保存。

This will force it to be downloaded instead of displayed in your browser.这将强制它被下载而不是显示在您的浏览器中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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