Skip to content

Instantly share code, notes, and snippets.

@ericclemmons
Created February 29, 2012 19:22
Show Gist options
  • Save ericclemmons/1943750 to your computer and use it in GitHub Desktop.
Save ericclemmons/1943750 to your computer and use it in GitHub Desktop.
Rackspace Cloudfiles API - Copy File with Curl
# We need to get an AUTH TOKEN first
curl -X GET -D - \
-H "X-Auth-User: $USER" \
-H "X-Auth-Key: $API_KEY" \
https://auth.api.rackspacecloud.com/v1.0 \
# HTTP/1.1 204 No Content
# Server: Apache/2.2.3 (Red Hat)
# vary: X-Auth-Token,X-Auth-Key,X-Storage-User,X-Storage-Pass
# X-Storage-Url: https://storage101.ord1.clouddrive.com/v1/MossoCloud-something-something
# Cache-Control: s-maxage=47325
# Content-Type: text/xml
# Date: Wed, 29 Feb 2012 17:03:11 GMT
# X-Auth-Token: 536bade1-various-other-values-here
# X-Server-Management-Url: https://servers.api.rackspacecloud.com/v1.0/55some-other-numbers
# X-Storage-Token: 536bade1-this-value-is-not-used
# Connection: Keep-Alive
# X-CDN-Management-Url: https://cdn2.clouddrive.com/v1/MossoCloudFS_some-other-value
# Content-Length: 0
# Put it together to copy an existing file to a new location (assuming within the same container)
curl -X PUT -D - \
-H "X-Auth-Token: $AUTH_TOKEN" \
-H "X-Copy-From: /$CONTAINER/$SOURCE" \
-H "Content-Length: 0" \
$STORAGE_URL/$CONTAINER/$DESTINATION
@ericclemmons
Copy link
Author

As you can tell, my only pre-existing variables are USER, API_KEY, CONTAINER, SOURCE and DESTINATION. (SOURCE and DESTINATION would be something like my_old_file.zip and my_new_file.zip, respectively).

The variables AUTH_TOKEN and STORAGE_URL come from your authentication request, which is crucial for this to work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment