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

Merge pull request #3228 from anynines/openstack_public_url

implements the public_url feature for openstack storage
This commit is contained in:
Wesley Beary 2014-10-30 10:14:28 -05:00
commit 0136ab1cb9
3 changed files with 43 additions and 2 deletions

View file

@ -9,7 +9,7 @@ module Fog
attribute :bytes, :aliases => 'X-Container-Bytes-Used'
attribute :count, :aliases => 'X-Container-Object-Count'
attr_writer :public
def destroy
@ -30,7 +30,15 @@ module Fog
end
def public_url
raise NotImplementedError
requires :key
@public_url ||= begin
begin response = service.head_container(key)
# escape the key to cover for special char. in container names
url = service.public_url(key)
rescue Fog::Storage::OpenStack::NotFound => err
nil
end
end
end
def save

View file

@ -0,0 +1,32 @@
module Fog
module Storage
class OpenStack
class Real
def url
"#{@scheme}://#{@host}:#{@port}#{@path}"
end
# Get public_url for an object
#
# ==== Parameters
# * container<~String> - Name of container to look in
# * object<~String> - Name of object to look for
#
def public_url(container=nil, object=nil)
public_url = nil
unless container.nil?
if object.nil?
# return container public url
public_url = "#{url}/#{Fog::OpenStack.escape(container)}"
else
# return object public url
public_url = "#{url}/#{Fog::OpenStack.escape(container)}/#{Fog::OpenStack.escape(object)}"
end
end
public_url
end
end
end
end
end

View file

@ -36,6 +36,7 @@ module Fog
request :put_dynamic_obj_manifest
request :put_static_obj_manifest
request :post_set_meta_temp_url_key
request :public_url
class Mock
def self.data