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.
-
#policy ⇒ Object
Returns the value of attribute policy.
Class Method Summary collapse
Instance Method Summary collapse
- #acl ⇒ Object
- #condition(key) ⇒ Object
- #conditions ⇒ Object
-
#initialize(params) ⇒ FileUpload
constructor
A new instance of FileUpload.
- #signature ⇒ Object
- #success_action_redirect ⇒ Object
Constructor Details
#initialize(params) ⇒ FileUpload
Returns a new instance of FileUpload.
24 25 26 27 28 |
# File 'lib/ungulate/file_upload.rb', line 24 def initialize(params) self.bucket_url = params[:bucket_url] self.key = params[:key] self.policy = params[:policy] 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 |
#policy ⇒ Object
Returns the value of attribute policy.
3 4 5 |
# File 'lib/ungulate/file_upload.rb', line 3 def policy @policy end |
Class Method Details
.enqueue(job_description) ⇒ Object
15 16 17 |
# File 'lib/ungulate/file_upload.rb', line 15 def self.enqueue(job_description) queue.(job_description.to_yaml) end |
.queue ⇒ Object
19 20 21 22 |
# File 'lib/ungulate/file_upload.rb', line 19 def self.queue sqs = RightAws::SqsGen2.new(access_key_id, secret_access_key) sqs.queue(queue_name) end |
Instance Method Details
#acl ⇒ Object
30 31 32 |
# File 'lib/ungulate/file_upload.rb', line 30 def acl condition 'acl' end |
#condition(key) ⇒ Object
34 35 36 37 |
# File 'lib/ungulate/file_upload.rb', line 34 def condition(key) found_key, found_value = conditions.find {|condition| condition.first == key} found_value if found_value end |
#conditions ⇒ Object
39 40 41 42 |
# File 'lib/ungulate/file_upload.rb', line 39 def conditions @conditions ||= @policy_ruby['conditions'].map {|condition| condition.to_a.flatten} end |
#signature ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/ungulate/file_upload.rb', line 55 def signature Base64.encode64( OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_access_key, policy) ).gsub("\n", '') end |
#success_action_redirect ⇒ Object
51 52 53 |
# File 'lib/ungulate/file_upload.rb', line 51 def success_action_redirect condition 'success_action_redirect' end |