Class: AWSRaw::S3::Request
- Inherits:
-
Object
- Object
- AWSRaw::S3::Request
- Defined in:
- lib/awsraw/s3/request.rb
Overview
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
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #content_md5 ⇒ Object
- #host ⇒ Object
-
#initialize(params, signer) ⇒ Request
constructor
A new instance of Request.
- #path ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(params, signer) ⇒ Request
Returns a new instance of Request.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
33 34 35 |
# File 'lib/awsraw/s3/request.rb', line 33 def bucket @bucket end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
37 38 39 |
# File 'lib/awsraw/s3/request.rb', line 37 def content @content end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
36 37 38 |
# File 'lib/awsraw/s3/request.rb', line 36 def headers @headers end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
34 35 36 |
# File 'lib/awsraw/s3/request.rb', line 34 def key @key end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
32 33 34 |
# File 'lib/awsraw/s3/request.rb', line 32 def method @method end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
35 36 37 |
# File 'lib/awsraw/s3/request.rb', line 35 def query @query end |
Instance Method Details
#content_md5 ⇒ Object
59 60 61 |
# File 'lib/awsraw/s3/request.rb', line 59 def content_md5 @content_md5 ||= Base64.encode64(MD5Digester.new(content).digest).strip end |
#host ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/awsraw/s3/request.rb', line 39 def host if @region && @region != US_STANDARD "s3-#{@region}.amazonaws.com" else "s3.amazonaws.com" end end |
#path ⇒ Object
47 48 49 |
# File 'lib/awsraw/s3/request.rb', line 47 def path @path ||= URI.escape("/#{bucket}#{key}") end |
#uri ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/awsraw/s3/request.rb', line 51 def uri @uri ||= URI::HTTP.build( :host => host, :path => path, :query => query ) end |