pythonrackspacepyrax

How can I get permanent URL of file uploaded on rackspace using python pyrax


I am able to to upload image successfully. My code is:

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

Solution

  • You can acquire a publicly-accessible URI of an object by joining its name with the cdn_uri or cdn_ssn_url of its container:

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