diff --git a/lib/fog/aws/requests/storage/post_object_restore.rb b/lib/fog/aws/requests/storage/post_object_restore.rb new file mode 100644 index 000000000..e50ee4730 --- /dev/null +++ b/lib/fog/aws/requests/storage/post_object_restore.rb @@ -0,0 +1,54 @@ +module Fog + module Storage + class AWS + class Real + + # Restore an object from Glacier to its original S3 path + # + # @param bucket_name [String] Name of bucket containing object + # @param object_name [String] Name of object to restore + # @option days [Integer] Number of days to restore object for. Defaults to 100000 (a very long time) + # + # @return [Excon::Response] response: + # * status [Integer] 200 + # + # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPOSTrestore.html + # + def post_object_restore(bucket_name, object_name, days = 100000) + unless bucket_name + raise ArgumentError.new('bucket_name is required') + end + unless object_name + raise ArgumentError.new('object_name is required') + end + + data = '' + days.to_s + '' + + headers = {} + headers['Content-MD5'] = Base64.encode64(Digest::MD5.digest(data)).strip + headers['Content-Type'] = 'application/xml' + headers['Date'] = Fog::Time.now.to_date_header + + request({ + :headers => headers, + :host => "#{bucket_name}.#{@host}", + :expect => 202, + :body => data, + :method => 'POST', + :query => {'restore' => nil}, + :path => CGI.escape(object_name) + }) + end + + end + + class Mock # :nodoc:all + + def post_object_restore(bucket_name, object_name, days = 100000) + raise "TODO" + end + + end + end + end +end diff --git a/lib/fog/aws/storage.rb b/lib/fog/aws/storage.rb index 74b1f3bfa..134e10845 100644 --- a/lib/fog/aws/storage.rb +++ b/lib/fog/aws/storage.rb @@ -33,6 +33,7 @@ module Fog response-content-language response-content-type response-expires + restore torrent uploadId uploads @@ -87,6 +88,7 @@ module Fog request :list_multipart_uploads request :list_parts request :post_object_hidden_fields + request :post_object_restore request :put_bucket request :put_bucket_acl request :put_bucket_cors @@ -217,7 +219,7 @@ module Fog :path => path, :headers => headers, }) - + # ret.delete(:path_style) ret.delete(:bucket_name) @@ -490,7 +492,7 @@ DATA expires = Fog::Time.now.to_date_header signature = signature(params, expires) - + params = request_params(params) params.delete(:port) unless params[:port]