简体   繁体   English

Apache LibCloud和Rackspace Cloudfiles

[英]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) 我已经开始将Apache libcloud库与python结合使用,以便可以与python3中的机架空间云文件进行通信(pyrax仅2个)

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: 不幸的是,我似乎只能获取上传项目的HTTP网址:

 driver.get_object_cdn_url(obj) 

This will return the HTTP url for the object I've just uploaded. 这将返回我刚刚上传的对象的HTTP URL。

Is there a way to get the OTHER url(s) (HTTPS / Streaming etc) via this library (I can't fathom it from the documentation!) 有没有办法通过此库获取其他网址(HTTPS /流式传输等)(我无法从文档中了解它!)

The driver allows you to first enable CDN functionality on the container. 该驱动程序允许您首先在容器上启用CDN功能。

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. 没有直接获取流URL的方法, get_container_cdn_url仅使用静态CDN URL进行响应。 This code snippet would get the information directly from the API: 此代码段将直接从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. 有关详细信息,请参见这些参考文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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