This section shows examples of how to use curl to execute different requests.
Example input:
curl -i http://zfssa:80/auth/v1.0 -X GET -H "X-Auth-User: user" -H "X-Auth-Key: key" curl -i http://zfssa:80/auth/v1.0/export/fs1 -X GET -H "X-Auth-User: user" -H "X-Auth-Key: key"
Example output:
HTTP/1.1 200 OK Date: Wed, 04 Apr 2018 15:09:39 GMT Server: Apache X-Storage-Url: http://zfssa:80/object/v1/export/fs1 X-Storage-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f X-Auth-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f Content-Length: 0 X-Trans-Id: tx8f482f16643e495eadee4-0056d45f34
The following example input creates a container named containerA:
curl -i http://zfssa:80/v1/export/fs1/containerA -X PUT -H "Content-Length: 0" -H "X-Auth-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f"
Example input:
curl -i http://zfssa:80/object/v1/export/fs1 -X GET -H "X-Auth-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f"
Example output:
HTTP/1.1 200 OK Date: Wed, 04 Apr 2018 13:48:57 GMT Server: Apache X-Timestamp: 1491400137.51 X-Account-Object-Count: 39 X-Account-Container-Count: 3 X-Account-Bytes-Used: 9823586 X-Trans-Id: tx1fd6145d8b3d4d9fdf0a8-0058e4f5c9 Transfer-Encoding: chunked Content-Type: text/plain; charset=utf-8 cont1 container2 test2
Example input:
curl "http://zfssa:80/v1/export/fs1?format=json" -X GET -H "X-Auth-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f" | python -mjson.tool
Example output:
[ { "bytes": 1664, "count": 5, "name": "cont1", …. }, { "bytes": 8902134, "count": 25, "name": "container2", …. }, { "bytes": 919788, "count": 9, "name": "test2", … } ]
Example input:
curl -i "http://zfssa:80/v1/export/fs1/cont1" -X GET -H "X-Auth-Token: ZFSSA_efcd2042-1a05-11e7-baf9-80144f20c6bc"
Example output:
HTTP/1.1 200 OK Date: Wed, 04 Apr 2018 14:01:16 GMT X-Container-Bytes-Used: 1664 … X-Container-Object-Count: 5 … source.conf source.conf_cam_rev source.conf_chena source.conf_demo source.sh ]
Example input:
curl "http://zfssa:80/v1/export/fs1/cont1?format=json" -X GET -H "X-Auth-Token: ZFSSA_efcd2042-1a05-11e7-baf9-80144f20c6bc" | python -mjson.tool
Example output:
[ { "bytes": 360, "content_type": "None", "hash": "d3ca560c566fb522e5cb3d923ffd398a", "last_modified": "2018-03-08T00:21:18", "name": "source.conf" }, { "bytes": 229, "content_type": "None", "hash": "cde5bd3e14dc1a1f6182a09f38b9c7f5", "last_modified": "2018-03-08T00:21:12", "name": "source.conf_cam_rev" }, { "bytes": 223, "content_type": "None", "hash": "264d93bd075da83fd2f027bf96eb508f", "last_modified": "2018-03-08T00:21:15", "name": "source.conf_chena" }, { "bytes": 375, "content_type": "None", "hash": "21b1e9e1378a825ac026ced97cccc6b9", "last_modified": "2018-03-08T00:21:16", "name": "source.conf_demo" }, { "bytes": 477, "content_type": "None", "hash": "2b79330805bd6c6163404b5ec85ea776", "last_modified": "2018-03-08T00:21:12", "name": "source.sh" } ]
Example input:
curl -i http://zfssa:80/v1/export/fs1/cont1/image.jpg -X PUT -H "X-Auth-Token: ZFSSA_efcd2042-1a05-11e7-baf9-80144f20c6bc" -T image.jpg
Example output:
HTTP/1.1 201 Created Date: Wed, 04 Apr 2018 14:24:17 GMT Etag: 93e67dc3fc447b9a368dafa03cbf4aa7
Example input:
curl -i http://zfssa:80/v1/export/fs1/cont1/image.jpg -X DELETE -H "X-Auth-Token: ZFSSA_efcd2042-1a05-11e7-baf9-80144f20c6bc"
Example output:
HTTP/1.1 204 No Content Date: Wed, 04 Apr 2018 14:27:34 GMT …
Example input:
curl http://zfssa:80/v1/export/fs1/cont1/image.jpg -X GET -H "X-Auth-Token: ZFSSA_efcd2042-1a05-11e7-baf9-80144f20c6bc" -O
A user's metadata can be done as part of a PUT operation when uploading the object, or a POST operation (updating an existing object). In this example, the user's metadata is tagged as movie and the value is comedy.
Example input:
curl -i http://zfssa:80/v1/export/fs1/cont1/source.conf_demo -X POST -H "X-Object-Meta-Movie: comedy” -H "X-Auth-Token: ZFSSA_efcd2042-1a05-11e7-baf9-80144f20c6bc"
Getting metadata of an object does not download the content of the object.
Example input:
curl -i http://zfssa:80/v1/export/fs1/cont1/source.conf_demo -I -H "X-Auth-Token: ZFSSA_efcd2042-1a05-11e7-baf9-80144f20c6bc"
Example output:
HTTP/1.1 200 OK Content-Length: 375 … X-Object-Meta-MOVIE: comedy …
In this example, image.jpg is copied from container cont1 to container cont2 on the same account.
Example input:
curl -i -X PUT -H "Content-Length: 0" -H "X-Auth-Token: ZFSSA_efcd2042-1a05-11e7-baf9-80144f20c6bc" -H "X-Copy-From: /cont1/image.jpg" http://zfssa:80/v1/export/fs1/cont2/image.jpg
Example output:
HTTP/1.1 201 Created Date: Wed, 04 Apr 2018 15:24:21 GMT X-Object-Meta-MTIME: 1491401363.904874 X-Copied-From: cont1/image.jpg … Etag: 93e67dc3fc447b9a368dafa03cbf4aa7 X-Copy-From-Account: user X-Copied-From-Last-Modified: 1491402764 …
The following examples show how to create a container to archive objects, enable versioning on that container, upload several versions of an object, and then show the archive for the container.
Create a container to archive objects:
curl -i http://zfssa:80/v1/export/fs1/archive -X PUT -H "Content-Length: 0" -H "X-Auth-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f"
Enable versioning on a container:
curl -i http://zfssa:80/v1/export/fs1/container1 -X PUT -H "Content-Length: 0" -H "X-Auth-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f" -H "X-Versions-Location: archive"
Upload object to container 'container1':
echo xx > example.txt curl -i http://zfssa:80/v1/export/fs1/container1/example.txt -X PUT -H "X-Auth-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f" -T example.txt
Modify object and upload it again:
echo yy > example.txt curl -i http://zfssa:80/v1/export/fs1/container1/example.txt -X PUT -H "X-Auth-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f" -T example.txt
List container1 content:
curl -i http://zfssa:80/v1/export/fs1/container1 -H "X-Auth-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f" HTTP/1.1 200 OK ..... X-Container-Object-Count: 1 X-Versions-Location: archive .... f.txt
List archive content:
curl -i http://zfssa:80/v1/export/fs1/archive -H "X-Auth-Token: ZFSSA_4607de64-def4-11e5-9326-7b36bda5fa3f" X-Container-Bytes-Used: 33 ... X-Container-Object-Count: 2 ... 005example.txt/1493210484.16 005example.txt/1493210812.52
List archive content using swift:
swift -A http://zfssa:80/v1/export/fs1/archive -U user -K key list -l archive 15 2018-04-26 12:41:24 f.txt 18 2018-04-26 12:46:52 f.txt 33