Module: AWS::S3::ACL::S3Object::ClassMethods

Defined in:
lib/aws/s3/acl.rb

Instance Method Summary collapse

Instance Method Details

#acl(name, bucket = nil, policy = nil) ⇒ Object

The acl method is the single point of entry for reading and writing access control list policies for a given object.

# Fetch the acl for the 'kiss.jpg' object in the 'marcel' bucket
policy = S3Object.acl 'kiss.jpg', 'marcel'

# Modify the policy ...
# ...

# Send updated policy back to the S3 servers
S3Object.acl 'kiss.jpg', 'marcel', policy


554
555
556
557
558
559
560
561
562
563
564
565
566
567
# File 'lib/aws/s3/acl.rb', line 554

def acl(name, bucket = nil, policy = nil)
  # We're using the second argument as the ACL::Policy
  if bucket.is_a?(ACL::Policy)
    policy = bucket
    bucket = nil
  end

  bucket = bucket_name(bucket)
  path   = path!(bucket, name) << '?acl'

  respond_with ACL::Policy::Response do
    policy ? put(path, {}, policy.to_xml) : ACL::Policy.new(get(path).policy)
  end
end