如何使用 aws-s3 gem 或 right_aws gem 更改 S3 存储桶中所有文件的文件权限
有没有办法使用 aws-s3 gem 或 right_aws gem 更改 S3 存储桶中每个文件的权限?
我在文档中找不到它。我必须单独处理每个文件吗?
我想授予“所有人”查看权限。
Is there a way to change the permission of every single file in a S3 bucket using either aws-s3 gem or right_aws gem?
I can't find it in the documentation. Do I have to do each file individually?
I would like to grant "everyone" view permission.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不相信这些 gem 应该设置权限,这可能是您在文档中找不到此功能的原因。在 AWS 控制台中或通过其 API 设置权限,亚马逊还提供用于设置 S3 权限的命令行工具。
gem aws-s3(可能还有 right_aws)用于从 ruby 读取和存储 S3 中的文件。设置权限是一个有点不同的规则。
I do not believe these gems are supposed to set permissions, that might be the reason you do not find this feature in the docs. Set your permissions in AWS console or through their API, amazon also has command line tools for setting S3 permissions.
The gem aws-s3 (and probably right_aws as well) is for reading and storing files in S3 from ruby. Setting permissions is a bit different discipline.
RightAws::S3::Grantee.new(key, "http://acs.amazonaws.com/groups/global/AllUsers", ["READ"], :apply, "AllUsers") 对我有用。
RightAws::S3::Grantee.new(key, "http://acs.amazonaws.com/groups/global/AllUsers", ["READ"], :apply, "AllUsers") works for me.
根据文档,gem 为 S3Object 提供了一个
acl=
方法。您可以非常轻松地迭代存储桶中的每个对象,并以编程方式在每个对象上设置 acl。http://docs.aws.amazon .com/AWSRubySDK/latest/AWS/S3/S3Object.html#acl%3D-instance_method
According to the docs, the gem provides an
acl=
method for S3Object. You can pretty easily iterate through each object in the bucket and programmatically set the acl on each object.http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/S3Object.html#acl%3D-instance_method