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

发布于 2024-10-12 07:51:05 字数 543 浏览 8 评论 0原文

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

}

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

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

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

心房的律动 2024-10-19 07:51:06

目前,s3 支持的标准 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浏览器免费软件也支持此功能:
http://s3browser.com/s3-bucket-cors-configuration.php

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

Access-Control-Allow-* headers are not supported at this time: 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

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

哎呦我呸! 2024-10-19 07:51:06

今天,Amazon 宣布完全支持 CORS,因此您现在可以使用 HTML5 进行拖放等操作。将文件直接拖放到 Amazon S3。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文