Class: Ungulate::FileUpload
- Inherits:
-
Object
- Object
- Ungulate::FileUpload
- Defined in:
- lib/ungulate/file_upload.rb
Instance Attribute Summary collapse
-
#bucket_url ⇒ Object
Returns the value of attribute bucket_url.
-
#key ⇒ Object
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
- #acl ⇒ Object
- #condition(key) ⇒ Object
- #conditions ⇒ Object
-
#initialize(options = {}) ⇒ FileUpload
constructor
A new instance of FileUpload.
- #policy ⇒ Object
- #policy=(new_policy) ⇒ Object
- #signature ⇒ Object
- #success_action_redirect ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ FileUpload
Returns a new instance of FileUpload.
23 24 25 26 27 28 29 30 |
# File 'lib/ungulate/file_upload.rb', line 23 def initialize( = {}) self.bucket_url = [:bucket_url] self.key = [:key] if [:policy] self.policy = [:policy] end end |
Instance Attribute Details
#bucket_url ⇒ Object
Returns the value of attribute bucket_url.
3 4 5 |
# File 'lib/ungulate/file_upload.rb', line 3 def bucket_url @bucket_url end |
#key ⇒ Object
Returns the value of attribute key.
3 4 5 |
# File 'lib/ungulate/file_upload.rb', line 3 def key @key end |
Class Method Details
.enqueue(job_description) ⇒ Object
14 15 16 |
# File 'lib/ungulate/file_upload.rb', line 14 def self.enqueue(job_description) queue.(job_description.to_yaml) end |
.queue ⇒ Object
18 19 20 21 |
# File 'lib/ungulate/file_upload.rb', line 18 def self.queue sqs = RightAws::SqsGen2.new(access_key_id, secret_access_key) sqs.queue(queue_name) end |
Instance Method Details
#acl ⇒ Object
32 33 34 |
# File 'lib/ungulate/file_upload.rb', line 32 def acl condition 'acl' end |
#condition(key) ⇒ Object
36 37 38 39 |
# File 'lib/ungulate/file_upload.rb', line 36 def condition(key) found_key, found_value = conditions.find {|condition| condition.first == key} found_value if found_value end |
#conditions ⇒ Object
41 42 43 44 |
# File 'lib/ungulate/file_upload.rb', line 41 def conditions @conditions ||= @policy_ruby['conditions'].map {|condition| condition.to_a.flatten} end |
#policy ⇒ Object
46 47 48 49 50 |
# File 'lib/ungulate/file_upload.rb', line 46 def policy Base64.encode64( ActiveSupport::JSON.encode(@policy_ruby) ).gsub("\n", '') end |
#policy=(new_policy) ⇒ Object
52 53 54 55 56 |
# File 'lib/ungulate/file_upload.rb', line 52 def policy=(new_policy) new_policy['expiration'] = new_policy['expiration'].utc @policy_ruby = new_policy policy end |
#signature ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/ungulate/file_upload.rb', line 62 def signature Base64.encode64( OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_access_key, policy) ).gsub("\n", '') end |
#success_action_redirect ⇒ Object
58 59 60 |
# File 'lib/ungulate/file_upload.rb', line 58 def success_action_redirect condition 'success_action_redirect' end |