class Wedge::Plugins::Uploader::S3Signature

Public Instance Methods

policy() click to toggle source
# File lib/wedge/plugins/uploader.rb, line 14
def policy
  Base64.encode64(policy_data.to_json).gsub("\n", "")
end
signature() click to toggle source
# File lib/wedge/plugins/uploader.rb, line 18
def signature
  # The presence of the “headers” property in the JSON request alerts your server to the fact that this is a request to sign a REST/multipart request and not a policy document.
  # Your server only needs to return the following in the body of an “application/json” response:
  encode_string = policy_data["headers"].present? ? policy_data["headers"] : policy

  Base64.encode64(
    OpenSSL::HMAC.digest(
      OpenSSL::Digest.new('sha1'),
      settings[:aws_secret_access_key], encode_string
    )
  ).gsub("\n", "")
end