Created
February 29, 2012 19:22
-
-
Save ericclemmons/1943750 to your computer and use it in GitHub Desktop.
Rackspace Cloudfiles API - Copy File with Curl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As you can tell, my only pre-existing variables are
USER,API_KEY,CONTAINER,SOURCEandDESTINATION. (SOURCEandDESTINATIONwould be something likemy_old_file.zipandmy_new_file.zip, respectively).The variables
AUTH_TOKENandSTORAGE_URLcome from your authentication request, which is crucial for this to work :)