Question

When uploading new asset into the CloudFiles storage I want to get public URL of this asset (if container is CDN-enabled). I figured out the only way to do this is to issue 3 (yes, three!) requests to RackSpace:

  1. Authenticate user and get x-auth-token, x-storage-url and x-cdn-management-url.
  2. After getting all the tokens and URLs, upload a file to the container.
  3. Issue a HEAD request to the x-cdn-management-url for public URL of the container.

I just want to make sure that I really need 3 requests per upload to get the public URL of the asset I just uploaded. All the operations must be performed programmatically via API.

Was it helpful?

Solution

I believe that once you have your container's CDN URL, every object you put in it is appended to it. So, if your container's CDN URL is cdn1.foo.cloudstorage.com, your objects will have the URLs cdn1.foo.cloudstorage.com/object1.ext, cdn1.foo.cloudstorage.com/object2.ext, etc.

You only need the three steps to get the initial container CDN URL. Afterwards, it's simple.

OTHER TIPS

If you're using Java, PHP, or Python, checkout one of the Rackspace SDKs. For examples on how to use CDN with each see:

  1. Java: CloudFilesPublish.java
  2. PHP: cdn.php
  3. Python: container_cdn.py
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top