class AWSRaw::S3::Client

A client for the AWS S3 rest API.

docs.amazonwebservices.com/AmazonS3/latest/API/APIRest.html

Public Class Methods

new(access_key_id, secret_access_key) click to toggle source
# File lib/awsraw/s3/client.rb, line 18
def initialize(access_key_id, secret_access_key)
  @access_key_id     = access_key_id
  @secret_access_key = secret_access_key
end

Public Instance Methods

request(params = {}) click to toggle source
# File lib/awsraw/s3/client.rb, line 23
def request(params = {})
  request = Request.new(params, signer)

  http_request = HTTPRequestBuilder.new(request).build

  http_response = Net::HTTP.start(request.uri.host, request.uri.port) do |http|
    http.request(http_request)
  end

  construct_response(http_response)
end
request!(params = {}) click to toggle source
# File lib/awsraw/s3/client.rb, line 35
def request!(params = {})
  response = request(params)
  raise ConnectionError, response.inspect if response.failure?
end

Private Instance Methods

construct_response(http_response) click to toggle source
# File lib/awsraw/s3/client.rb, line 42
def construct_response(http_response)
  Response.new(
    :code    => http_response.code,
    :headers => http_response.to_hash,
    :content => http_response.body
  )
end
signer() click to toggle source
# File lib/awsraw/s3/client.rb, line 50
def signer
  @signer ||= Signer.new(@access_key_id, @secret_access_key)
end