Class: Wedge::Plugins::Uploader::S3Signature

Inherits:
Struct
  • Object
show all
Defined in:
lib/wedge/plugins/uploader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#policy_dataObject

Returns the value of attribute policy_data

Returns:

  • (Object)

    the current value of policy_data



13
14
15
# File 'lib/wedge/plugins/uploader.rb', line 13

def policy_data
  @policy_data
end

#settingsObject

Returns the value of attribute settings

Returns:

  • (Object)

    the current value of settings



13
14
15
# File 'lib/wedge/plugins/uploader.rb', line 13

def settings
  @settings
end

Instance Method Details

#policyObject



14
15
16
# File 'lib/wedge/plugins/uploader.rb', line 14

def policy
  Base64.encode64(policy_data.to_json).gsub("\n", "")
end

#signatureObject



18
19
20
21
22
23
24
25
26
27
28
29
# 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