简体   繁体   English

Amazon S3:使用aws-sdk-ruby设置权限

[英]Amazon S3: set permissions using aws-sdk-ruby

I'm getting Access Denied for a new images path in S3. 我在S3中由于新的图像路径而被拒绝访问 This in the same bucket, that I have worked with and for other images everything is fine. 这与我一起使用过的存储桶相同,对于其他图像,一切都很好。 Can it be a permissions issue? 可以是权限问题吗? If so, how can I get (and set) permissions using aws-sdk-ruby ? 如果是这样,我如何使用aws-sdk-ruby获得(设置)权限?

The documentation has poor examples and I don't have access to amazon dashboard. 该文档的示例很差,我无法访问Amazon仪表板。

Can I do these manipulations through the gem anyway? 我是否可以通过宝石进行这些操作?

From their docs @ aws-sdk doc 来自他们的文档@ aws-sdk doc
als you may want to reference the bucket doc 还可以参考存储分区文档

S3 supports a number of canned ACLs for buckets and objects. S3支持许多针对存储桶和对象的罐头ACL。 These include: 这些包括:

:private
:public_read
:public_read_write
:authenticated_read
:bucket_owner_read (object-only)
:bucket_owner_full_control (object-only)
:log_delivery_write (bucket-only)

Here is an example of providing a canned ACL to a bucket: 以下是向存储桶提供罐装ACL的示例:

s3.buckets['bucket-name'].acl = :public_read

The syntax has changed on 语法已更改

gem 'aws-sdk', '~> 2' 宝石'aws-sdk','〜> 2'

It is now with round brackets, instead of square. 现在它带有圆括号,而不是正方形。 and in singular 并且单数

s3.bucket(object) 

instead of 代替

s3.buckets[object]

Full-Example : 完整示例:

s3 = Aws::S3::Resource.new
source = s3.bucket('bucket-name').object('some/path/filename.txt')
destination = s3.bucket('same-or-other-bucket').object('destination/filename2.txt')

copy_to(destination, acl:'public-read')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM