Apache LibCloud and Rackspace Cloudfiles

75 views Asked by At

I've started using the Apache libcloud library with python to allow me to talk to rackspace cloudfiles in python3 (pyrax is 2 only)

I've got this running successfully and am uploading files / creating containers etc happily.

Sadly, I appear to only be able to get the HTTP url for the items uploaded:

driver.get_object_cdn_url(obj)

This will return the HTTP url for the object I've just uploaded.

Is there a way to get the OTHER url(s) (HTTPS / Streaming etc) via this library (I can't fathom it from the documentation!)

1

There are 1 answers

0
anthony shaw On

The driver allows you to first enable CDN functionality on the container.

driver.enable_container_cdn(container)

There isn't a method to directly get the streaming URL, get_container_cdn_url only responds with the static CDN URL. This code snippet would get the information directly from the API:

from libcloud.utils.py3 import urlquote
container_name = '<your container name'
response = driver.connection.request('/%s' % (urlquote(container_name)),
                                       method='HEAD',
                                       cdn_request=True)
uri = response.headers['x-cdn-uri']
ssl_uri = response.headers['x-cdn-ssl-uri']
stream_uri = response.headers['x-cdn-streaming-uri']

See these reference docs for details.