Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I know it's a bit off topic, but I wanted to share my 'workflow' which may help a lot of people.</p> <p>If you download these two cool toys (replacement for curl and python's json):</p> <ul> <li><a href="https://github.com/jkbr/httpie" rel="nofollow">https://github.com/jkbr/httpie</a></li> <li><a href="http://stedolan.github.io/jq/" rel="nofollow">http://stedolan.github.io/jq/</a></li> </ul> <p>Then you can do all these fun things:</p> <p>(Just replace USER and KEY with your real user and key in the 1st line, and all the others are copy and paste-able.</p> <p>Get the json:</p> <pre><code>json=$(echo '{ "auth":{ "RAX-KSKEY:apiKeyCredentials":{ "username":"USER", "apiKey":"KEY" } } }' | http POST https://auth.api.rackspacecloud.com/v2.0/tokens) </code></pre> <p>Get token with http:</p> <pre><code>token=$(echo $json | jq '.access | .token | .id' | sed s/\"//g) </code></pre> <p>Easy token usage for later:</p> <pre><code>auth="X-Auth-Token:$token" </code></pre> <p>Get endpoint for Sydney cloud files (change SYD for your favorite Datacenter) (change publicURL to internalURL if you're running from inside the DC):</p> <pre><code>url=$(echo $json | jq '.access | .serviceCatalog | .[] | select(.name == "cloudFiles") | .endpoints | .[] | select(.region == "SYD") | .publicURL' | sed s/\"//g) </code></pre> <p>-- Hard work is done. Now it gets easy --</p> <p>Get list of containers:</p> <pre><code>http "$url" $auth </code></pre> <p>Create a container:</p> <pre><code>http PUT "$url/my_container" $auth </code></pre> <p>Upload a file:</p> <pre><code>cat python1.JPG | http PUT "$url/my_container/python1.jpg" $auth </code></pre> <p>List files:</p> <pre><code>http "$url/my_container" </code></pre> <p>Get CDN API URL (not the one for downloading, that's later):</p> <pre><code>cdn_url=$(echo $json | jq ' .access | .serviceCatalog | .[] | select(.name == "cloudFilesCDN") | .endpoints | .[] | select(.region == "SYD") | .publicURL' | sed s/\"//g) </code></pre> <p>CDN enable the container:</p> <pre><code>http PUT "$cdn_url/my_container" $auth "X-Cdn-Enabled: True" </code></pre> <p>Get public CDN url for my_container:</p> <pre><code>pub_url=$(http -h HEAD "$cdn_url/my_container" $auth | awk '/X-Cdn-Uri/{print $2;}') </code></pre> <p>View your file:</p> <pre><code>firefox "$pub_url/python1.jpg" </code></pre> <p>All the API docs are here: <a href="http://docs.rackspace.com/files/api/v1/cf-devguide/content/API_Operations_for_Storage_Services-d1e942.html" rel="nofollow">http://docs.rackspace.com/files/api/v1/cf-devguide/content/API_Operations_for_Storage_Services-d1e942.html</a></p> <p>Enjoy :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload