class AWSRaw::S3::Request

Note that we use path style (rather than virtual hosted style) requests. This is because virtual hosted requests only support lower case bucket names.

See docs.amazonwebservices.com/AmazonS3/latest/dev/VirtualHosting.html

Attributes

bucket[R]
content[R]
headers[R]
key[R]
method[R]
query[R]

Public Class Methods

new(params, signer) click to toggle source
# File lib/awsraw/s3/request.rb, line 16
def initialize(params, signer)
  @method  = params[:method]
  @bucket  = params[:bucket]
  @region  = params[:region]
  @key     = params[:key]
  @query   = params[:query]
  @headers = params[:headers] || {}
  @content = params[:content]

  raise "Content without Content-Type" if !@content.nil? && @headers["Content-Type"].nil?

  headers["Content-MD5"]   = content_md5 unless content.nil?
  headers["Date"]          = Time.now.rfc2822
  headers["Authorization"] = signer.signature(self)
end

Public Instance Methods

content_md5() click to toggle source
# File lib/awsraw/s3/request.rb, line 59
def content_md5
  @content_md5 ||= Base64.encode64(MD5Digester.new(content).digest).strip
end
host() click to toggle source
# File lib/awsraw/s3/request.rb, line 39
def host
  if @region && @region != US_STANDARD
    S3.configuration.regional_hosts[@region]
  else
    S3.configuration.host
  end
end
path() click to toggle source
# File lib/awsraw/s3/request.rb, line 47
def path
  @path ||= URI.escape("/#{bucket}#{key}")
end
uri() click to toggle source
# File lib/awsraw/s3/request.rb, line 51
def uri
  @uri ||= URI::HTTP.build(
    :host  => host,
    :path  => path,
    :query => query
  )
end