Upload a directory to Rackspace Cloud Files from command lineWed 02 January 2013 by Thejaswi Puthraya
Here's a simple bash script that uploads a directory to Rackspace Cloud Files and may later on be served as a static website.
First we have to authenticate to get the authentication token that has to be passed for every request:
$ curl -v -X GET -H "X-Auth-User: <username>" -H "X-Auth-Key: <api_key>" "https://identity.api.rackspacecloud.com/v1.0"
Copy the X-Auth-Token and X-Storage-Url from the response.
Change into a directory that you want to upload and run the following command:
for ii in `find ./ -name '*'|cut -b 3-|grep -v -P '^$'`; do curl -X PUT -T $ii -H "X-Auth-Token: <auth_token>" "<storage_url>/<container_name>/$ii"; done