1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Changed Atmos::FIle.public_url so an exception is thrown if the file doesn't exist on the cloud storage

This commit is contained in:
Michael Harrison 2012-10-22 19:33:59 +10:00
parent be9f885429
commit e054b855df

View file

@ -57,21 +57,22 @@ module Fog
# By default, expire in 5 years
def public_url(expires = (Time.now + 5 * 365 * 24 * 60 * 60))
file = directory.files.head(key)
if file.present?
self.objectid = file.attributes['x-emc-meta'].scan(/objectid=(\w+),/).flatten[0] if self.objectid.blank?
requires :objectid
uri = URI::HTTP.build(:scheme => connection.ssl? ? "http" : "https" , :host => connection.host, :port => connection.port.to_i, :path => "/rest/objects/#{self.objectid}" )
sb = "GET\n"
sb += uri.path.downcase + "\n"
sb += connection.uid + "\n"
sb += String(expires.to_i())
signature = connection.sign( sb )
uri.query = "uid=#{CGI::escape(connection.uid)}&expires=#{expires.to_i()}&signature=#{CGI::escape(signature)}"
uri.to_s
if self.objectid.blank?
file = directory.files.head(key)
self.objectid = file.attributes['x-emc-meta'].scan(/objectid=(\w+),/).flatten[0] if file.present?
end
requires :objectid
uri = URI::HTTP.build(:scheme => connection.ssl? ? "http" : "https" , :host => connection.host, :port => connection.port.to_i, :path => "/rest/objects/#{self.objectid}" )
sb = "GET\n"
sb += uri.path.downcase + "\n"
sb += connection.uid + "\n"
sb += String(expires.to_i())
signature = connection.sign( sb )
uri.query = "uid=#{CGI::escape(connection.uid)}&expires=#{expires.to_i()}&signature=#{CGI::escape(signature)}"
uri.to_s
end
def save(options = {})