Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #363 from minter/add_rackspace_cdn_cname_support

Add support for specifying a CDN CNAME when getting a Rackspace Cloud Files directory
  • Loading branch information...
commit 0ca0df13b7312e1fc685ae593c212959df5ff7aa 2 parents 7934cfb + 2c85294
Wesley Beary authored
View
6 lib/fog/storage/models/rackspace/directories.rb
@@ -14,9 +14,13 @@ def all
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)
View
3  lib/fog/storage/models/rackspace/directory.rb
@@ -11,6 +11,7 @@ class Directory < Fog::Model
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 @@ def public_url
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
Please sign in to comment.
Something went wrong with that request. Please try again.