如何使用python pyrax获取在rackspace上上传的文件的永久URL

时间:2014-09-08 07:05:44

标签: python rackspace pyrax

我能够成功上传图片。 我的代码是:

pyrax.set_setting("identity_type", "rackspace")
pyrax.set_credentials("myuser_name", "my_api_key", region="ORD")
cf = pyrax.cloudfiles
cont = cf.create_container("media")
cont.make_public()
print "Beginning upload..."
obj = cont.upload_file(app.config['UPLOAD_FOLDER'] + "/" + str(filename))
print obj.get_temp_url
print cont

1 个答案:

答案 0 :(得分:3)

您可以通过将其名称与其容器的cdn_uricdn_ssn_url相关联来获取对象的公共可访问URI:

# Public URI
cont.cdn_uri + '/' + obj.name

# Public SSL URI
cont.cdn_ssl_uri + '/' + obj.name