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

Bag*_*ggz 23 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
Run Code Online (Sandbox Code Playgroud)

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

}
Run Code Online (Sandbox Code Playgroud)

S3 *_*eam 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