Class: PostToS3::FileUpload
- Inherits:
-
Object
- Object
- PostToS3::FileUpload
- Defined in:
- lib/post_to_s3/file_upload.rb
Instance Attribute Summary collapse
-
#acl ⇒ Object
readonly
Returns the value of attribute acl.
-
#bucket_url ⇒ Object
readonly
Returns the value of attribute bucket_url.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
-
#success_action_redirect ⇒ Object
readonly
Returns the value of attribute success_action_redirect.
Instance Method Summary collapse
- #access_key_id ⇒ Object
-
#initialize(options = {}) ⇒ FileUpload
constructor
A new instance of FileUpload.
- #signature ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ FileUpload
Returns a new instance of FileUpload.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/post_to_s3/file_upload.rb', line 8 def initialize( = {}) @bucket_url = [:bucket_url] @key = [:key] @policy = [:policy] if @policy @policy['expiration'] = @policy['expiration'].utc @conditions = @policy['conditions'].map {|condition| condition.to_a.flatten } @acl, @success_action_redirect = Hash[@conditions].values_at('acl', 'success_action_redirect') @policy = Base64.encode64(ActiveSupport::JSON.encode(@policy)).gsub("\n", '') end end |
Instance Attribute Details
#acl ⇒ Object (readonly)
Returns the value of attribute acl.
5 6 7 |
# File 'lib/post_to_s3/file_upload.rb', line 5 def acl @acl end |
#bucket_url ⇒ Object (readonly)
Returns the value of attribute bucket_url.
5 6 7 |
# File 'lib/post_to_s3/file_upload.rb', line 5 def bucket_url @bucket_url end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
5 6 7 |
# File 'lib/post_to_s3/file_upload.rb', line 5 def conditions @conditions end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/post_to_s3/file_upload.rb', line 5 def key @key end |
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
5 6 7 |
# File 'lib/post_to_s3/file_upload.rb', line 5 def policy @policy end |
#success_action_redirect ⇒ Object (readonly)
Returns the value of attribute success_action_redirect.
5 6 7 |
# File 'lib/post_to_s3/file_upload.rb', line 5 def success_action_redirect @success_action_redirect end |
Instance Method Details
#access_key_id ⇒ Object
27 28 29 |
# File 'lib/post_to_s3/file_upload.rb', line 27 def access_key_id config.access_key_id end |
#signature ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/post_to_s3/file_upload.rb', line 31 def signature Base64.encode64( OpenSSL::HMAC.digest( OpenSSL::Digest::Digest.new('sha1'), config.secret_access_key, policy )).gsub("\n", '') end |