class S3Relay::PrivateUrl
Attributes
expires[R]
path[R]
Public Class Methods
new(uuid, file, options={})
click to toggle source
# File lib/s3_relay/private_url.rb, line 6 def initialize(uuid, file, options={}) filename = Addressable::URI.escape(file).gsub("+", "%2B") @path = [uuid, filename].join("/") @expires = (options[:expires] || 10.minutes.from_now).to_i end
Public Instance Methods
generate()
click to toggle source
# File lib/s3_relay/private_url.rb, line 12 def generate "#{endpoint}/#{path}?#{params}" end
Private Instance Methods
params()
click to toggle source
# File lib/s3_relay/private_url.rb, line 18 def params [ "AWSAccessKeyId=#{access_key_id}", "Expires=#{expires}", "Signature=#{signature}" ].join("&") end
signature()
click to toggle source
# File lib/s3_relay/private_url.rb, line 26 def signature string = "GET\n\n\n#{expires}\n/#{bucket}/#{path}" hmac = OpenSSL::HMAC.digest(digest, secret_access_key, string) CGI.escape(Base64.encode64(hmac).strip) end