Created
June 5, 2012 16:51
-
-
Save drewkerrigan/2876196 to your computer and use it in GitHub Desktop.
Swift Usage Examples
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
Execute the following command and make a note of X-Auth-Token. You will need this token to use in all subsequent commands. | |
curl -v -H 'X-Storage-User: system:root' -H 'X-Storage-Pass: testpass' http://10.80.83.68:8077/auth/v1.0 | |
In the following command examples we are using 'AUTH_tk65840af9f6f74d1aaefac978cb8f0899' as the X-Auth-Token. Replace this with the appropriate token you obtained in the above step. | |
To create a container: | |
curl -X PUT -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer | |
To list all containers in current account: | |
curl -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/ | |
Uploading a file "file1" to container "mycontainer" | |
curl -X PUT -T file1 -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer/ | |
To list all objects in a container: | |
curl -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer | |
To list all objects in a container that starts with a particular prefix "fi": | |
curl -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer/?prefix=fi | |
To download a particular file "file1" from the container "mycontainer": | |
curl -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer/file1 | |
To download file1 and save it locally as localfile1: | |
curl -o localfile1 -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer/file1 | |
To delete a container "mycontainer" | |
curl -X DELETE -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer | |
To delete a specific file "file1" from the container: | |
curl -X DELETE -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer/file1 | |
To get metadata associated with a Swift account: | |
curl -v -X HEAD -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/ | |
To get metadata associated with a container: | |
curl -v -X HEAD -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer | |
You can request the data from Swift in XML or JSON format by specifying the "format" paramater. This parameter can be applied to any of the above requests. Here are a few examples: | |
curl -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/?format=json | |
curl -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/?format=xml | |
The above operations can also be done using 'swift' command. For instructions on using 'swift' command, please refer to "swift --help". |
--to list file metadata (file size, last modifiled time, etc) , use the -I option, -X HEAD wont work
curl -I -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer/file1
Is there curl command to do bulk delete ?
Hi all
does anyone know if curl will work with or using tempurl?
Also, with the URL above, is that with SWIFT auth or KEYSTONE auth? Thanks
One more thing, has anyone gotten SWIFT to work with a NGINX in front? our SWIFT is behind firewall, so I am trying to configure a reverse proxy to pass everything. if anyone can share their experience. would be appreciated. Thanks all
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 14:
curl -X PUT -T file1 -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer/
Did not work for me. I had specify the filename in the URL as follow: http://10.80.83.68:8077/v1/AUTH_system/mycontainer/file1 in order to see the object in the next steps.
Everything else is super useful thanks for the post.