Class: Synaptic4r::StorageRequest

Inherits:
Object
  • Object
show all
Includes:
StorageRest
Defined in:
lib/synaptic4r/request.rb

Overview



Instance Method Summary collapse

Methods included from StorageRest

included

Instance Method Details

#get_object_url(args) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….…… other requests .….….….….….….….….….….….….….….….….….….….….….….….….……



280
281
282
283
284
285
286
287
288
289
# File 'lib/synaptic4r/request.rb', line 280

def get_object_url(args)
  esc = '/=&?%'
  exp = (args[:lifetime].nil? ? 5 : args[:lifetime].to_i)*60 + Time.now.to_i
  res = /.*(\/rest.*)/.match(url).captures.first
  user = headers['x-emc-uid']
  @sign = "GET\n" + "#{res.downcase}\n#{user}\n#{exp}"
  digest = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), Base64.decode64(key), sign)
  signature = Base64.encode64(digest.to_s())
  @url = "#{url}?uid=#{URI.encode(user, esc)}&expires=#{exp}&signature=#{URI.encode(signature, esc)}"
end