简体   繁体   中英

Apache LibCloud and Rackspace Cloudfiles

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!)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM