javascript Amazon S3 和跨域资源共享 (CORS)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4717006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 14:38:51  来源:igfitidea点击:

Amazon S3 and Cross-Origin Resource Sharing (CORS)

javascriptajaxamazon-s3amazon-web-servicescors

提问by Baggz

Does Amazon S3 allow custom headers? Or am I out of luck?

Amazon S3 是否允许自定义标头?还是我运气不好?

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: X-SOMETHING
Access-Control-Max-Age: 1728000

Example

例子

var request = new XMLHttpRequest();
var url = 'http://example.s3.amazonaws.com/templates/welcome.html';

function callOtherDomain(){

    request.open('GET', url, true);
    request.withCredentials = "true";
    request.onreadystatechange = handler;
    request.send();

}

回答by user686782

回答by S3 Browser Team

Currently, there is limited number of standrd http headers supported by s3.

目前,s3 支持的标准 http 标头数量有限。

Access-Control-Allow-* headers are not supported at this time: https://forums.aws.amazon.com/thread.jspa?threadID=34281&tstart=0

目前不支持 Access-Control-Allow-* 标头:https://forums.aws.amazon.com/thread.jspa?threadID=34281&tstart =0

UPDATE:

更新:

Support for Cross-Origin Resource Sharing is added: https://forums.aws.amazon.com/ann.jspa?annID=1620

添加了对跨域资源共享的支持:https: //forums.aws.amazon.com/ann.jspa?annID=1620

S3 Browser Freeware also supports this feature: http://s3browser.com/s3-bucket-cors-configuration.php

S3 浏览器免费软件也支持此功能:http: //s3browser.com/s3-bucket-cors-configuration.php

回答by Skyler Johnson

回答by VAAA

Today Amazon announces the complete support for CORS, so you can now use HTML5 for example for Drag & Drop files directly to Amazon S3.

今天亚马逊宣布完全支持 CORS,因此您现在可以使用 HTML5 将文件直接拖放到 Amazon S3。