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

Add support for specifying a CDN CNAME when getting a Rackspace Cloud Files directory.

This commit is contained in:
H. Wade Minter 2011-06-16 16:22:37 -04:00
parent b4b6375c72
commit 2c852945c9
2 changed files with 7 additions and 2 deletions

View file

@ -14,9 +14,13 @@ module Fog
load(data) load(data)
end end
# Supply the :cdn_cname option to use the Rackspace CDN CNAME functionality on the public_url.
#
# > fog.directories.get('video', :cdn_cname => 'http://cdn.lunenburg.org').files.first.public_url
# => 'http://cdn.lunenburg.org/hayley-dancing.mov'
def get(key, options = {}) def get(key, options = {})
data = connection.get_container(key, options) data = connection.get_container(key, options)
directory = new(:key => key) directory = new(:key => key, :cdn_cname => options[:cdn_cname])
for key, value in data.headers for key, value in data.headers
if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key) if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key)
directory.merge_attributes(key => value) directory.merge_attributes(key => value)

View file

@ -11,6 +11,7 @@ module Fog
attribute :bytes, :aliases => 'X-Container-Bytes-Used' attribute :bytes, :aliases => 'X-Container-Bytes-Used'
attribute :count, :aliases => 'X-Container-Object-Count' attribute :count, :aliases => 'X-Container-Object-Count'
attribute :cdn_cname
def destroy def destroy
requires :key requires :key
@ -42,7 +43,7 @@ module Fog
if connection.rackspace_cdn_ssl == true if connection.rackspace_cdn_ssl == true
response.headers['X-CDN-SSL-URI'] response.headers['X-CDN-SSL-URI']
else else
response.headers['X-CDN-URI'] cdn_cname || response.headers['X-CDN-URI']
end end
end end
rescue Fog::Service::NotFound rescue Fog::Service::NotFound