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

openstack storage: add possibility to set publicity to containers

This commit is contained in:
A.S. Lomoff 2014-08-09 23:00:21 +03:00
parent a5e5d102a3
commit 9c1d617513
2 changed files with 8 additions and 7 deletions

View file

@ -9,6 +9,8 @@ module Fog
attribute :bytes, :aliases => 'X-Container-Bytes-Used'
attribute :count, :aliases => 'X-Container-Object-Count'
attr_accessor :public
def destroy
requires :key
@ -27,17 +29,13 @@ module Fog
end
end
def public=(new_public)
@public = new_public
end
def public_url
raise NotImplementedError
end
def save
requires :key
service.put_container(key)
service.put_container(key, :public => @public)
true
end
end

View file

@ -7,11 +7,14 @@ module Fog
# ==== Parameters
# * name<~String> - Name for container, should be < 256 bytes and must not contain '/'
#
def put_container(name)
def put_container(name, options={})
headers = options[:headers] || {}
headers['X-Container-Read'] = '.r:*' if options[:public]
request(
:expects => [201, 202],
:method => 'PUT',
:path => Fog::OpenStack.escape(name)
:path => Fog::OpenStack.escape(name),
:headers => headers
)
end
end