lib/fog/aws/requests/s3/get_object.rb in fog-0.0.5 vs lib/fog/aws/requests/s3/get_object.rb in fog-0.0.6

- old
+ new

@@ -21,21 +21,28 @@ # * headers<~Hash>: # * 'Content-Length'<~String> - Size of object contents # * 'Content-Type'<~String> - MIME type of object # * 'ETag'<~String> - Etag of object # * 'Last-Modified'<~String> - Last modified timestamp for object - def get_object(bucket_name, object_name, options = {}) + def get_object(bucket_name, object_name, options = {}, &block) + unless bucket_name + raise ArgumentError.new('bucket_name is required') + end + unless object_name + raise ArgumentError.new('object_name is required') + end headers = {} headers['If-Modified-Since'] = options['If-Modified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since'] headers['If-Unmodified-Since'] = options['If-Unmodified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since'] headers.merge!(options) request({ :expects => 200, :headers => headers, :host => "#{bucket_name}.#{@host}", :method => 'GET', - :path => object_name + :path => object_name, + :block => block }) end end end @@ -46,9 +53,15 @@ module Fog module AWS class S3 def get_object(bucket_name, object_name, options = {}) + unless bucket_name + raise ArgumentError.new('bucket_name is required') + end + unless object_name + raise ArgumentError.new('object_name is required') + end response = Fog::Response.new if (bucket = Fog::AWS::S3.data[:buckets][bucket_name]) && (object = bucket[:objects][object_name]) if options['If-Match'] && options['If-Match'] != object['ETag'] response.status = 412 elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['LastModified'])