Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting public URL of newly uploaded CloudFiles asset

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.

like image 908
Pono Avatar asked Dec 04 '25 22:12

Pono


2 Answers

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.

like image 183
Tabasco HotSauce Avatar answered Dec 08 '25 07:12

Tabasco HotSauce


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
like image 20
Everett Toews Avatar answered Dec 08 '25 08:12

Everett Toews



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!