Method: Fog::AWS::S3#get_object
- Defined in:
-
lib/fog/aws/requests/s3/get_object.rb,
lib/fog/aws/requests/s3/get_object.rb
Get an object from S3
bucket_name<~String> - Name of bucket to read from
object_name<~String> - Name of object to read
options<~Hash>:
‘If-Match’<~String> - Returns object only if its etag matches this value, otherwise returns 412 (Precondition Failed).
‘If-Modified-Since’<~Time> - Returns object only if it has been modified since this time, otherwise returns 304 (Not Modified).
‘If-None-Match’<~String> - Returns object only if its etag differs from this value, otherwise returns 304 (Not Modified)
‘If-Unmodified-Since’<~Time> - Returns object only if it has not been modified since this time, otherwise returns 412 (Precodition Failed).
‘Range’<~String> - Range of object to download
response<~Excon::Response>:
body<~String> - Contents of object
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
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fog/aws/requests/s3/get_object.rb', line 26 def get_object(bucket_name, object_name, = {}, &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'] = ['If-Modified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if ['If-Modified-Since'] headers['If-Unmodified-Since'] = ['If-Unmodified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if ['If-Modified-Since'] headers.merge!() request({ :expects => 200, :headers => headers, :host => "#{bucket_name}.#{@host}", :idempotent => true, :method => 'GET', :path => CGI.escape(object_name), :block => block }) end |