Class: ActiveAdmin::Editor::Policy
- Inherits:
-
Object
- Object
- ActiveAdmin::Editor::Policy
- Defined in:
- lib/active_admin/editor/policy.rb
Overview
Public: Class used to generate a new S3 policy document, which can be used to authorize a direct upload to an S3 bucket.
Examples
policy = Policy.new
# => #<ActiveAdmin::Editor::Policy:0x007fa9ec41f440>
policy.document
# => "eyJleHBpcmF0aW9uIjo...gwMDBdXX0="
policy.signature
# => "NakHRb4SaI8cpU5RtSVh25kj/sc="
Instance Method Summary collapse
-
#document ⇒ Object
Public: The base64 encoded policy document.
-
#signature ⇒ Object
Public: The base64 encoded signature of the policy document.
-
#to_json ⇒ Object
Public: JSON representation of the policy.
Instance Method Details
#document ⇒ Object
Public: The base64 encoded policy document.
25 26 27 |
# File 'lib/active_admin/editor/policy.rb', line 25 def document @document ||= Base64.encode64(document_hash.to_json).gsub("\n", '') end |
#signature ⇒ Object
Public: The base64 encoded signature of the policy document. Signed with the s3 access secret.
31 32 33 |
# File 'lib/active_admin/editor/policy.rb', line 31 def signature @signature ||= Base64.encode64(digest).gsub("\n", '') end |
#to_json ⇒ Object
Public: JSON representation of the policy.
36 37 38 |
# File 'lib/active_admin/editor/policy.rb', line 36 def to_json { :document => document, :signature => signature }.to_json end |