Class: Happening::AWS
Constant Summary collapse
- AMAZON_HEADER_PREFIX =
'x-amz-'
- AMAZON_METADATA_PREFIX =
'x-amz-meta-'
- DIGEST =
OpenSSL::Digest.new('sha1')
Instance Attribute Summary collapse
-
#aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
-
#aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
Instance Method Summary collapse
-
#initialize(aws_access_key_id, aws_secret_access_key) ⇒ AWS
constructor
A new instance of AWS.
- #sign(method, path, headers = {}) ⇒ Object
Constructor Details
#initialize(aws_access_key_id, aws_secret_access_key) ⇒ AWS
Returns a new instance of AWS.
12 13 14 15 16 |
# File 'lib/happening/aws.rb', line 12 def initialize(aws_access_key_id, aws_secret_access_key) @aws_access_key_id = aws_access_key_id @aws_secret_access_key = aws_secret_access_key raise ArgumentError, "need AWS Access Key Id and AWS Secret Key" if blank?(aws_access_key_id) || blank?(aws_secret_access_key) end |
Instance Attribute Details
#aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
10 11 12 |
# File 'lib/happening/aws.rb', line 10 def aws_access_key_id @aws_access_key_id end |
#aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
10 11 12 |
# File 'lib/happening/aws.rb', line 10 def aws_secret_access_key @aws_secret_access_key end |
Instance Method Details
#sign(method, path, headers = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/happening/aws.rb', line 18 def sign(method, path, headers={}) headers = { 'date' => utc_httpdate }.update(headers) request_description = canonical_request_description(method, path, headers) headers.update("Authorization" => "AWS #{aws_access_key_id}:#{generate_signature(request_description)}") end |