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
- #access_key_id ⇒ Object
- #acl ⇒ Object
- #condition(key) ⇒ Object
- #conditions ⇒ Object
- #config ⇒ 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.
21 22 23 24 25 26 27 28 |
# File 'lib/ungulate/file_upload.rb', line 21 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.
5 6 7 |
# File 'lib/ungulate/file_upload.rb', line 5 def bucket_url @bucket_url end |
#key ⇒ Object
Returns the value of attribute key.
5 6 7 |
# File 'lib/ungulate/file_upload.rb', line 5 def key @key end |
Class Method Details
.config ⇒ Object
8 9 10 |
# File 'lib/ungulate/file_upload.rb', line 8 def config Ungulate.configuration end |
.enqueue(job_description) ⇒ Object
16 17 18 |
# File 'lib/ungulate/file_upload.rb', line 16 def enqueue(job_description) queue.push(job_description.to_yaml) end |
.queue ⇒ Object
12 13 14 |
# File 'lib/ungulate/file_upload.rb', line 12 def queue @queue ||= config.queue.call end |
Instance Method Details
#access_key_id ⇒ Object
34 35 36 |
# File 'lib/ungulate/file_upload.rb', line 34 def access_key_id config.access_key_id end |
#acl ⇒ Object
38 39 40 |
# File 'lib/ungulate/file_upload.rb', line 38 def acl condition 'acl' end |
#condition(key) ⇒ Object
42 43 44 45 |
# File 'lib/ungulate/file_upload.rb', line 42 def condition(key) found_key, found_value = conditions.find {|condition| condition.first == key} found_value if found_value end |
#conditions ⇒ Object
47 48 49 50 |
# File 'lib/ungulate/file_upload.rb', line 47 def conditions @conditions ||= @policy_ruby['conditions'].map {|condition| condition.to_a.flatten} end |
#config ⇒ Object
30 31 32 |
# File 'lib/ungulate/file_upload.rb', line 30 def config self.class.config end |
#policy ⇒ Object
52 53 54 55 56 |
# File 'lib/ungulate/file_upload.rb', line 52 def policy Base64.encode64( ActiveSupport::JSON.encode(@policy_ruby) ).gsub("\n", '') end |
#policy=(new_policy) ⇒ Object
58 59 60 61 62 |
# File 'lib/ungulate/file_upload.rb', line 58 def policy=(new_policy) new_policy['expiration'] = new_policy['expiration'].utc @policy_ruby = new_policy policy end |
#signature ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/ungulate/file_upload.rb', line 68 def signature Base64.encode64( OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), config.secret_access_key, policy) ).gsub("\n", '') end |
#success_action_redirect ⇒ Object
64 65 66 |
# File 'lib/ungulate/file_upload.rb', line 64 def success_action_redirect condition 'success_action_redirect' end |