[英]How to set the Access-Control-Allow-Origin header on an AWS S3 object using Ruby SDK?
How do you set the Access-Control-Allow-Origin
header of an S3 object using version 1 of the AWS SDK for Ruby. 如何使用适用于Ruby的AWS开发工具包的版本1设置S3对象的
Access-Control-Allow-Origin
标头。 The docs here show how to set a variety of headers, but there doesn't seem to be anything for the access control header. 此处的文档显示了如何设置各种标头,但访问控制标头似乎没有任何内容。 It does mention a
:metadata
option, but that prefixes the values with x-amz-meta
, which is not what I'm looking for. 它的确提到了
:metadata
选项,但是该值以x-amz-meta
,这不是我想要的。
The reason I ask is because I'm trying to download a publicly readable file in S3 (which I put there) by making an Ajax call from Javascript. 我问的原因是因为我试图通过从Javascript进行Ajax调用来下载S3中的公共可读文件(放置在该文件中)。 I have set the ACL to public read, which means I can view it in a browser, but I get the
No 'Access-Control-Allow-Origin' header is present on the requested resource
error from the Ajax call. 我已经将ACL设置为公共读取,这意味着我可以在浏览器中查看它,但是在Ajax调用
No 'Access-Control-Allow-Origin' header is present on the requested resource
错误中,我No 'Access-Control-Allow-Origin' header is present on the requested resource
。
Well, is that the only way to do it?
好吧,这是唯一的方法吗?
Yes, that's the only way to do it. 是的,那是唯一的方法。 CORS in S3 is only configurable at the bucket level.
S3中的CORS只能在存储桶级别进行配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.