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 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 |
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
,SOURCE
andDESTINATION
. (SOURCE
andDESTINATION
would be something likemy_old_file.zip
andmy_new_file.zip
, respectively).The variables
AUTH_TOKEN
andSTORAGE_URL
come from your authentication request, which is crucial for this to work :)