lib/aws/s3/s3_object.rb in aws-sdk-1.7.1 vs lib/aws/s3/s3_object.rb in aws-sdk-1.8.0
- old
+ new
@@ -347,10 +347,35 @@
# using server side encryption.
def server_side_encryption?
!server_side_encryption.nil?
end
+ # @return [Boolean] whether a {#restore} operation on the
+ # object is currently being performed on the object.
+ # @see #restore_expiration_date
+ # @since 1.7.2
+ def restore_in_progress?
+ head.restore_in_progress
+ end
+
+ # @return [DateTime] the time when the temporarily restored object
+ # will be removed from S3. Note that the original object will remain
+ # available in Glacier.
+ # @return [nil] if the object was not restored from an archived
+ # copy
+ # @since 1.7.2
+ def restore_expiration_date
+ head.restore_expiration_date
+ end
+
+ # @return [Boolean] whether the object is a temporary copy of an
+ # archived object in the Glacier storage class.
+ # @since 1.7.2
+ def restored_object?
+ !!head.restore_expiration_date
+ end
+
# Deletes the object from its S3 bucket.
#
# @param [Hash] options
#
# @option [String] :version_id (nil) If present the specified version
@@ -379,10 +404,31 @@
nil
end
+ # Restores a temporary copy of an archived object from the
+ # Glacier storage tier. After the specified +days+, Amazon
+ # S3 deletes the temporary copy. Note that the object
+ # remains archived; Amazon S3 deletes only the restored copy.
+ #
+ # Restoring an object does not occur immediately. Use
+ # {#restore_in_progress?} to check the status of the operation.
+ #
+ # @option [Integer] :days (1) the number of days to keep the object
+ # @return [Boolean] +true+ if a restore can be initiated.
+ # @since 1.7.2
+ def restore options = {}
+ options[:days] ||= 1
+
+ client.restore_object(
+ :bucket_name => bucket.name,
+ :key => key, :days => options[:days])
+
+ true
+ end
+
# @option [String] :version_id (nil) If present the metadata object
# will be for the specified version.
# @return [ObjectMetadata] Returns an instance of ObjectMetadata
# representing the metadata for this object.
def metadata options = {}
@@ -1308,20 +1354,16 @@
Core::Signer.sign(secret, string_to_sign, 'sha1')
end
def expiration_timestamp(input)
+ input = input.to_int if input.respond_to?(:to_int)
case input
- when Time
- expires = input.to_i
- when DateTime
- expires = Time.parse(input.to_s).to_i
- when Integer
- expires = (Time.now + input).to_i
- when String
- expires = Time.parse(input).to_i
- else
- expires = (Time.now + 60*60).to_i
+ when Time then input.to_i
+ when DateTime then Time.parse(input.to_s).to_i
+ when Integer then (Time.now + input).to_i
+ when String then Time.parse(input).to_i
+ else (Time.now + 60*60).to_i
end
end
def http_method(input)
symbol = case input