lib/aws/s3/s3_object.rb in aws-sdk-1.0.3 vs lib/aws/s3/s3_object.rb in aws-sdk-1.0.4
- old
+ new
@@ -227,14 +227,16 @@
# will reject non-final parts smaller than 5MB, and the
# default for this option is 5MB.
#
# @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+.
+ # headers prefixed with +x-amz-meta+. Each name, value pair
+ # must conform to US-ASCII.
#
- # @option options [Symbol] :acl A canned access control
- # policy. Valid values are:
+ # @option options [Symbol] :acl (private) A canned access
+ # control policy. Valid values are:
+ #
# * +:private+
# * +:public_read+
# * +:public_read_write+
# * +:authenticated_read+
# * +:bucket_owner_read+
@@ -331,24 +333,26 @@
#
# @param [Hash] options Options for the upload.
#
# @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+.
+ # headers prefixed with +x-amz-meta+. Each name, value pair
+ # must conform to US-ASCII.
#
- # @option options [Symbol] :acl A canned access control
- # policy. Valid values are:
+ # @option options [Symbol] :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 [Boolean] :reduced_redundancy If true,
- # Reduced Redundancy Storage will be enabled for the
- # uploaded object.
+ # @option options [Boolean] :reduced_redundancy (false) If true,
+ # Reduced Redundancy Storage will be enabled for the uploaded
+ # object.
#
# @option options :cache_control [String] Can be used to specify
# caching behavior. See
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
#
@@ -401,22 +405,40 @@
# S3 handles the copy so the clients does not need to fetch the data
# and upload it again. You can also change the storage class and
# metadata of the object when copying.
#
# @param [Mixed] source
+ #
# @param [Hash] options
+ #
# @option options [String] :bucket_name The name of the bucket
# the source object can be found in. Defaults to the current
# object's bucket.
- # @option options [Bucket] :bucket The bucket the source object can
- # be found in. Defaults to the current object's bucket.
- # @option options [Hash] :metadata A hash of metadata to save with
- # the copied object. When blank, the sources metadata is copied.
+ #
+ # @option options [Bucket] :bucket The bucket the source object
+ # can be found in. Defaults to the current object's bucket.
+ #
+ # @option options [Hash] :metadata A hash of metadata to save
+ # with the copied object. Each name, value pair must conform
+ # to US-ASCII. When blank, the sources metadata is copied.
+ #
# @option options [Boolean] :reduced_redundancy (false) If true the
# object is stored with reduced redundancy in S3 for a lower cost.
- # @option options [String] :version_id (nil) Causes the copy to
+ #
+ # @option options [String] :version_id (nil) Causes the copy to
# read a specific version of the source object.
+ #
+ # @option options [Symbol] :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+
+ #
# @return [nil]
def copy_from source, options = {}
copy_opts = { :bucket_name => bucket.name, :key => key }
@@ -439,14 +461,18 @@
copy_opts[:metadata_directive] = 'REPLACE'
else
copy_opts[:metadata_directive] = 'COPY'
end
+ copy_opts[:acl] = options[:acl] if options[:acl]
copy_opts[:version_id] = options[:version_id] if options[:version_id]
- copy_opts[:storage_class] = 'REDUCED_REDUNDANCY' if
- options[:reduced_redundancy]
+ if options[:reduced_redundancy]
+ copy_opts[:storage_class] = 'REDUCED_REDUNDANCY'
+ else
+ copy_opts[:storage_class] = 'STANDARD'
+ end
client.copy_object(copy_opts)
nil
@@ -458,20 +484,28 @@
# and upload it again. You can also change the storage class and
# metadata of the object when copying.
#
# @param [S3Object,String] target An S3Object, or a string key of
# and object to copy to.
+ #
# @param [Hash] options
+ #
# @option options [String] :bucket_name The name of the bucket
# the object should be copied into. Defaults to the current object's
# bucket.
+ #
# @option options [Bucket] :bucket The bucket the target object
# should be copied into. Defaults to the current object's bucket.
- # @option options [Hash] :metadata A hash of metadata to save with
- # the copied object. When blank, the sources metadata is copied.
- # @option options [Boolean] :reduced_redundancy (false) If true the
- # object is stored with reduced redundancy in S3 for a lower cost.
+ #
+ # @option options [Hash] :metadata A hash of metadata to save
+ # with the copied object. Each name, value pair must conform
+ # to US-ASCII. When blank, the sources metadata is copied.
+ #
+ # @option options [Boolean] :reduced_redundancy (false) If true
+ # the object is stored with reduced redundancy in S3 for a
+ # lower cost.
+ #
# @return (see #copy_from)
def copy_to target, options = {}
unless target.is_a?(S3Object)
@@ -685,9 +719,26 @@
#
# @see PresignedPost
# @return [PresignedPost]
def presigned_post(options = {})
PresignedPost.new(bucket, options.merge(:key => key))
+ end
+
+ # @note Changing the storage class of an object incurs a COPY
+ # operation.
+ #
+ # Changes the storage class of the object to enable or disable
+ # Reduced Redundancy Storage (RRS).
+ #
+ # @param [true,false] value If this is true, the object will be
+ # copied in place and stored with reduced redundancy at a
+ # lower cost. Otherwise, the object will be copied and stored
+ # with the standard storage class.
+ #
+ # @return [true,false] The +value+ parameter.
+ def reduced_redundancy= value
+ copy_from(key, :reduced_redundancy => value)
+ value
end
# @private
private
def build_uri(secure, request)