all things web and not web

allskonar

Using AWS::S3

Now setting a object to :public_read is trivial if it’s done when you store it to S3. That doesn’t seem to be the case if you want to change on an object that already has been stored privately. After banging my head against it a bit I finally “got it” and I figured I would share it to either show off or try to be helpful.

dial into s3sh session see url above for details on how to store keys in environment variables etc.

once in there get a bucket object

  • my_bucket = Bucket.find(‘foo’)

now get the s3obj that you want to become public

  • s3obj = my_bucket[‘object_name’]
  • policy = s3obj.acl
  • grant = ACL::Grant.new
  • grant.permission = ‘READ’
  • grantee = ACL::Grantee.new
  • grantee.group = ‘AllUsers’
  • grant.grantee = grantee
  • policy.grants << grant
  • s3obj.acl(policy)

The access control on the buckets must be very rich since it’s this tricky make things public. I must be overlooking something.

Leave a Reply

 
allskonar Powered by Mephisto