lib/aws/s3/s3_object.rb in aws-sdk-1.5.4 vs lib/aws/s3/s3_object.rb in aws-sdk-1.5.5

- old
+ new

@@ -37,10 +37,11 @@ # class S3Object include Core::Model include DataOptions + include ACLOptions # @param [Bucket] bucket The bucket this object belongs to. # @param [String] key The object's key. def initialize(bucket, key, opts = {}) super @@ -245,20 +246,26 @@ # @option options [Hash] :metadata A hash of metadata to be # included with the object. These will be sent to S3 as # headers prefixed with +x-amz-meta+. Each name, value pair # must conform to US-ASCII. # - # @option options [Symbol] :acl (private) A canned access + # @option options [Symbol,String] :acl (:private) A canned access # control policy. Valid values are: # # * +:private+ # * +:public_read+ # * +:public_read_write+ # * +:authenticated_read+ # * +:bucket_owner_read+ # * +:bucket_owner_full_control+ # + # @option options [String] :grant_read + # @option options [String] :grant_write + # @option options [String] :grant_read_acp + # @option options [String] :grant_write_acp + # @option options [String] :grant_full_control + # # @option options [Symbol] :storage_class Controls whether # Reduced Redundancy Storage is enabled for the object. # Valid values are +:standard+ (the default) or # +:reduced_redundancy+. # @@ -291,15 +298,20 @@ # # @return [S3Object, ObjectVersion] If the bucket has versioning # enabled, returns the {ObjectVersion} representing the # version that was uploaded. If versioning is disabled, # returns self. + # def write(options_or_data = nil, options = nil) (data_options, put_options) = compute_put_options(options_or_data, options) + if acl = put_options[:acl] + put_options[:acl] = acl.to_s.tr('_', '-') + end + add_configured_write_options(put_options) if use_multipart?(data_options, put_options) put_options.delete(:multipart_threshold) multipart_upload(put_options) do |upload| @@ -745,24 +757,22 @@ acl.object = self acl end - # Sets the object's access control list. +acl+ can be: - # * An XML policy as a string (which is passed to S3 uninterpreted) - # * An AccessControlList object - # * Any object that responds to +to_xml+ - # * Any Hash that is acceptable as an argument to - # AccessControlList#initialize. - # - # @param (see Bucket#acl=) + # Sets the objects's ACL (access control list). You can provide an ACL + # in a number of different formats. + # @param (see ACLOptions#acl_options) # @return [nil] def acl=(acl) - client.set_object_acl( - :bucket_name => bucket.name, - :key => key, - :acl => acl) + + client_opts = {} + client_opts[:bucket_name] = bucket.name + client_opts[:key] = key + + client.put_object_acl(acl_options(acl).merge(client_opts)) nil + end # @private REQUEST_PARAMETERS = Request.query_parameters.map do |p| p.tr("-","_").to_sym