我有以下 S3 存储桶: http: //my-bucket.s3-website-eu-west-1.amazonaws.com/
根据http://docs.amazonwebservices.com/AmazonS3/latest/dev/cors.html,我添加了一个 CORS 配置:
<CORSConfiguration>
<CORSRule>
<AllowedHeader>x-requested-with</AllowedHeader>
<AllowedHeader>*</AllowedHeader>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>POST</AllowedMethod>
</CORSRule>
<CORSRule>
<AllowedOrigin>http://*.test.com</AllowedOrigin>
<AllowedMethod>POST</AllowedMethod>
</CORSRule>
</CORSConfiguration>
我使用 jquery 向我的存储桶发出 AJAX Post 请求(注意,来源是 jd.test.com:8000):
$.ajax('http://my-bucket.s3-website-eu-west-1.amazonaws.com/', {
type: "POST",
data: $(":hidden", self).serializeArray(),
files: $(":file", self),
statusCode: {
204: function(){
//do something
}
}
});
提出请求后,我的 chrome 控制台抱怨:
XMLHttpRequest cannot load http://my-bucket.s3-website-eu-west-1.amazonaws.com/. Origin http://www.jd.test.com:8000 is not allowed by Access-Control-Allow-Origin.
任何关于为什么没有发出 POST 请求的帮助将不胜感激。
谢谢 !