mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add a head method for the directories collection.
This commit is contained in:
parent
485419ec6c
commit
01157f1385
1 changed files with 27 additions and 0 deletions
|
@ -14,6 +14,33 @@ module Fog
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def head(key, options = {})
|
||||||
|
read_header = nil
|
||||||
|
write_header = nil
|
||||||
|
data = connection.head_container(key)
|
||||||
|
directory = new(:key => key)
|
||||||
|
for key, value in data.headers
|
||||||
|
if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key)
|
||||||
|
directory.merge_attributes(key => value)
|
||||||
|
end
|
||||||
|
if key == 'X-Container-Read'
|
||||||
|
read_header = value
|
||||||
|
elsif key == 'X-Container-Write'
|
||||||
|
write_header = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# set the acl on the directory based on the headers
|
||||||
|
if !(read_header.nil? && write_header.nil?)
|
||||||
|
directory.acl = connection.header_to_acl(read_header, write_header)
|
||||||
|
end
|
||||||
|
# set the cdn state for the directory
|
||||||
|
directory.cdn_enabled?
|
||||||
|
|
||||||
|
directory
|
||||||
|
rescue Fog::Storage::HP::NotFound
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def get(key, options = {})
|
def get(key, options = {})
|
||||||
read_header = nil
|
read_header = nil
|
||||||
write_header = nil
|
write_header = nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue