简体   繁体   中英

Rackspace CloudFile API - get object information

So, here's what I'm doing with the API:

  1. Auth (to get token and publicUrl for the particular region I need from the "object-store")

  2. Use the publicUrl from the endpoint like so to get a list of files: GET [publicUrl]/[container] This returns an array where each item (object) looks like the following:

    ( [hash] => 7213ee9a7d9dc119d2921a40e899ec5e [last_modified] => 2015-12-29T02:46:08.400490 [bytes] => 1 [name] => Some type of file name.jpg [content_type] => application/postscript )

Now, how do I build the url to do a GET on the item (object)? I've tried the following:

[publicUrl]/[container]/[hash] [publicUrl]/[container]/urlencoded([name])

among other things that don't make sense, but I tried anyway.

Any thoughts/help would be appreciated!

If you are using a Rackspace SDK , you can skip building the URLs yourself.

Here is the documentation for retrieving a Cloud Files object using a public URL . The object URL is the combination of the public URL of the container (found in the X-Cdn-Uri response header) with the object name appended.

For example, for a container named 'foo', send an authenticated HEAD request to the API:

HEAD {cloudFilesEndpoint}/foo

In the response, the container's public URL is in the 'X-Cdn-Uri' header:

HTTP/1.1 204 No Content
X-Cdn-Ssl-Uri: https://83c49b9a2f7ad18250b3-346eb45fd42c58ca13011d659bfc1ac1.ssl.cf0.rackcdn.com
X-Ttl: 259200
X-Cdn-Uri: http://081e40d3ee1cec5f77bf-346eb45fd42c58ca13011d659bfc1ac1.r49.cf0.rackcdn.com
X-Cdn-Enabled: True
X-Log-Retention: False
X-Cdn-Streaming-Uri: http://084cc2790632ccee0a12-346eb45fd42c58ca13011d659bfc1ac1.r49.stream.cf0.rackcdn.com
X-Trans-Id: tx82a6752e00424edb9c46fa2573132e2c
Content-Length: 0

Now, for an object named 'styles/site.css', append that name to the public URL, resulting in the following URL:

http://081e40d3ee1cec5f77bf-346eb45fd42c58ca13011d659bfc1ac1.r49.cf0.rackcdn.com/styles/site.css

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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