Class: Pail::Generate
- Inherits:
-
Object
- Object
- Pail::Generate
- Defined in:
- lib/pail.rb
Class Method Summary collapse
- .policy(bucket, expiration_date, acl, max_filesize) ⇒ Object
- .signature(secret_access_key, policy) ⇒ Object
Class Method Details
.policy(bucket, expiration_date, acl, max_filesize) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pail.rb', line 12 def self.policy(bucket, expiration_date, acl, max_filesize) Base64.encode64( "{'expiration': '#{expiration_date}', 'conditions': [ {'bucket': '#{bucket}'}, {'acl': '#{acl}'}, {'success_action_status': '201'}, ['content-length-range', 0, #{max_filesize}], ['starts-with', '$key', ''], ['starts-with', '$Content-Type', ''], ['starts-with', '$name', ''], ['starts-with', '$Filename', ''] ] }" ).gsub(/\n|\r/, '') end |
.signature(secret_access_key, policy) ⇒ Object
6 7 8 9 10 |
# File 'lib/pail.rb', line 6 def self.signature(secret_access_key, policy) Base64.encode64( OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), secret_access_key, policy) ).gsub("\n","") end |