1
0
Fork 0
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:
Rupak Ganguly 2012-07-13 18:12:07 -04:00
parent 485419ec6c
commit 01157f1385

View file

@ -14,6 +14,33 @@ module Fog
load(data)
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 = {})
read_header = nil
write_header = nil