Class: AwsSigner::Signature
- Inherits:
-
Object
- Object
- AwsSigner::Signature
- Defined in:
- lib/aws_signer/signature.rb
Constant Summary collapse
- REQUIRED_OPTIONS =
[:file_name, :mime_type]
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#expiration ⇒ Object
Public: The expiration of the signing request.
-
#initialize(options = {}) ⇒ Signature
constructor
Public: Initialize a Signature object.
-
#public_url ⇒ Object
Public: The public url for the file being uploaded.
-
#signed_url ⇒ Object
Public: The signed url for the file being uploaded.
-
#signed_url_params ⇒ Object
Public: The signed url parameters.
-
#to_json ⇒ Object
Public: The JSON representation of this object.
Constructor Details
#initialize(options = {}) ⇒ Signature
Public: Initialize a Signature object.
8 9 10 11 12 |
# File 'lib/aws_signer/signature.rb', line 8 def initialize( = {}) AwsSigner.validate_configuration! @options = Hashie::Mash.new(.merge()) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/aws_signer/signature.rb', line 5 def @options end |
Instance Method Details
#expiration ⇒ Object
Public: The expiration of the signing request.
Returns a timestamp in Integer format (in seconds).
45 46 47 |
# File 'lib/aws_signer/signature.rb', line 45 def expiration @expiration ||= Time.now.to_i + (60 * .request_expiration) end |
#public_url ⇒ Object
Public: The public url for the file being uploaded
Returns the url as a String.
17 18 19 |
# File 'lib/aws_signer/signature.rb', line 17 def public_url "#{AwsSigner.s3_base_url}/#{AwsSigner.upload_bucket}/#{file_path}" end |
#signed_url ⇒ Object
Public: The signed url for the file being uploaded. This includes the public url as well as all required signature parameters.
Returns the signed url as a String.
26 27 28 |
# File 'lib/aws_signer/signature.rb', line 26 def signed_url [public_url, signed_url_params.to_query].join('?') end |
#signed_url_params ⇒ Object
Public: The signed url parameters.
Returns a Hash of required parameters for signing the public url.
34 35 36 37 38 39 40 |
# File 'lib/aws_signer/signature.rb', line 34 def signed_url_params { 'AWSAccessKeyId' => AwsSigner.access_key_id, 'Expires' => expiration, 'Signature' => base64_encoded_signature } end |
#to_json ⇒ Object
Public: The JSON representation of this object.
Returns a Hash containing the public and signed urls that can be serialized into JSON.
53 54 55 56 57 58 |
# File 'lib/aws_signer/signature.rb', line 53 def to_json { :public_url => public_url, :signed_url => signed_url } end |