Amazon S3 和跨源资源共享 (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();
}
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
S3 现已正式支持 CORS:http://docs.amazonwebservices.com/AmazonS3/latest/dev/ cors.html
CORS is now officially supported on S3: http://docs.amazonwebservices.com/AmazonS3/latest/dev/cors.html
目前,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=0UPDATE:
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
可以在此处找到支持的 HTTP 标头列表:http:// docs.amazonwebservices.com/AmazonS3/latest/API/index.html?RESTObjectPUT.html
The list of supported HTTP headers can be found here: http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?RESTObjectPUT.html
今天,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.