http://docs.openstack.org/api/openstack-object-storage/1.0/content/storage-account-services.html
http://docs.openstack.org/trunk/openstack-compute/starter/content/ch05s01s02.html
以下操作皆可用 'swift' 指令 "swift --help" 查詢
獲得 X-Auth-Token
curl -v -H 'X-Storage-User: admin:admin' -H 'X-Storage-Pass: admin' http://10.10.10.2:8080/auth/v1.0
舉例,獲得的 X-Auth-Token:AUTH_tk3bb59eda987446c79160202d4dfbdc8c。其餘指令若須使用 X-Auth-Token 則帶入 "AUTH_tk3bb59eda987446c79160202d4dfbdc8c"。
To create a container:
curl -X PUT -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer
To list all containers in current account:
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/
Uploading a file "file1" to container "mycontainer"
curl -X PUT -T file1 -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/
To list all objects in a container:
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer
To list all objects in a container that starts with a particular prefix "fi":
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/?prefix=fi
To download a particular file "file1" from the container "mycontainer":
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/file1
To download file1 and save it locally as localfile1:
curl -o localfile1 -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/file1
To delete a container "mycontainer"
curl -X DELETE -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer
To delete a specific file "file1" from the container:
curl -X DELETE -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/file1
To get metadata associated with a Swift account:
curl -v -X HEAD -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/
To get metadata associated with a container:
curl -v -X HEAD -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/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_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/?format=json
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/?format=xml
沒有留言:
張貼留言