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

时间:2011-01-17 19:28:58

标签: javascript ajax amazon-s3 amazon-web-services cors

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

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

示例

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();

}

4 个答案:

答案 0 :(得分:44)

答案 1 :(得分:11)

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

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

更新:

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

S3 Browser Freeware也支持此功能: http://s3browser.com/s3-bucket-cors-configuration.php

答案 2 :(得分:3)

答案 3 :(得分:2)

今天亚马逊宣布完全支持CORS,因此您现在可以使用HTML5作为Drag& amp;将文件直接删除到Amazon S3。