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:
parent
b4b6375c72
commit
2c852945c9
2 changed files with 7 additions and 2 deletions
|
@ -14,9 +14,13 @@ module Fog
|
|||
load(data)
|
||||
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 = {})
|
||||
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
|
||||
if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key)
|
||||
directory.merge_attributes(key => value)
|
||||
|
|
|
@ -11,6 +11,7 @@ module Fog
|
|||
|
||||
attribute :bytes, :aliases => 'X-Container-Bytes-Used'
|
||||
attribute :count, :aliases => 'X-Container-Object-Count'
|
||||
attribute :cdn_cname
|
||||
|
||||
def destroy
|
||||
requires :key
|
||||
|
@ -42,7 +43,7 @@ module Fog
|
|||
if connection.rackspace_cdn_ssl == true
|
||||
response.headers['X-CDN-SSL-URI']
|
||||
else
|
||||
response.headers['X-CDN-URI']
|
||||
cdn_cname || response.headers['X-CDN-URI']
|
||||
end
|
||||
end
|
||||
rescue Fog::Service::NotFound
|
||||
|
|
Loading…
Reference in a new issue