Class: S3::ObjectGetRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/s3/object_get_request.rb

Constant Summary

Constants inherited from Request

Request::AWS_ALGORITHM, Request::AWS_REQUEST, Request::SERVICE, Request::UNSIGNED_PAYLOAD

Instance Method Summary collapse

Methods inherited from Request

#initialize

Constructor Details

This class inherits a constructor from S3::Request

Instance Method Details

#submit(bucket:, key:, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/s3/object_get_request.rb', line 3

def submit( bucket:, key:, &block )
  path = "/#{ bucket }/#{ Helpers.encode_key( key ) }"

  if block_given?
    response = get( path ) do |chunk, _bytes, _env|
      block.call( chunk )
    end

    build_result( response, NilClass ) do
      nil
    end
  else
    response = get( path )

    build_result( response, String ) do
      response.body
    end
  end
end