How can you do the equivalent of:
s3cmd setacl --acl-grant=read:82b82d14a8d011e09d86001cc029a3688cdd635ea8d011e0b499001cc029a3689052a4f4a8d011e0bd25001cc029a368 s3://somebucket/some/path/to/file
in Ruby? (preferably by using the 'aws-s3' gem)
=== Edit ===
As Soren suggests below, something similar to this should work:
grant = AWS::S3::ACL::Grant.new
grant.permission = 'READ'
grantee = AWS::S3::ACL::Grantee.new
grantee.id = '82b82d14a8d011e09d86001cc029a3688cdd635ea8d011e0b499001cc029a3689052a4f4a8d011e0bd25001cc029a368'
grant.grantee = grantee
acl = AWS::S3::S3Object.acl('some/path/to/file', 'somebucket')
acl.grants << grant
AWS::S3::S3Object.acl 'some/path/to/file', 'somebucket', acl
However that does not work, I get the following error:
The XML you provided was not well-formed or did not validate against our published schema (AWS::S3::MalformedACLError)
Any ideas how to make this work?
I can't get it to work with the 'aws-s3' gem, but it does work with the 'rightscale_aws' gem:
require 'right_aws'
s3 = RightAws::S3.new(access_key, secret_key, {:logger => Logger.new('/dev/null')})
bucket = s3.bucket('somebucket')
bucket.put 'some/path/to/file', open('/tmp/myfile')
access_id = '82b82d14a8d011e09d86001cc029a3688cdd635ea8d011e0b499001cc029a3689052a4f4a8d011e0bd25001cc029a368'
key = bucket.key('some/path/to/file')
RightAws::S3::Grantee.new(key, access_id, ['READ'], :apply)