Go to main content

Oracle® ZFS Storage Appliance Object API Guide for Swift Service Support, Release OS8.8.0

Exit Print View

Updated: January 2019
 
 

Swift Examples

The following examples show how to use the swift command-line client.


Note -  The HTTPS protocol is supported as well as HTTP.

List containers using the default path

swift -A http://zfssa:80/auth/v1.0 -U user -K key list

The output lists the containers that are part of an account.

List containers using a specified share location

swift -A http://zfssa:80/auth/v1.0/export/fs1 -U user -K key list

List objects in a container

swift -A http://zfssa:80/auth/v1.0/ -U user -K key list containerA

Create/upload object to container

swift -A http://zfssa:80/auth/v1.0/ -U user -K key upload containerA object1

Download container

swift -A http://zfssa:80/auth/v1.0/ -U user -K key download containerA

Delete container

swift -A http://zfssa:80/auth/v1.0/ -U user -K key delete containerA

Download object

swift -A http://zfssa:80/auth/v1.0/ -U user -K key download containerA object1

Delete object

swift -A http://zfssa:80/auth/v1.0/ -U user -K key delete containerA object1

Set metadata to an object

swift -A http://zfssa:80/auth/v1.0/ -U user -K key post containerA object1 --header "X-Object-Meta-Movie: comedy”

Get metadata from an object

swift -A http://zfssa:80/auth/v1.0/ -U user -K key stat -v containerA object1

Upload a large file with segments using Dynamic Large Object

Dynamic Large Object is a middleware component supported by Oracle ZFS Storage Appliance.

swift -A http://zfssa:80/auth/v1.0/ -U user -K key upload containerA large_file -S 100000000 

Download large file uploaded using Dynamic Large Object

Dynamic Large Object is a middleware component supported by Oracle ZFS Storage Appliance.

swift -A http://zfssa:80/auth/v1.0/ -U user -K key download containerA large_file

Bulk Delete or Bulk Upload

Bulk Delete and Bulk Upload are middleware components supported by Oracle ZFS Storage Appliance.

In the following example, three objects are created in a container called Various. A file called object_to_delete contains the name of the objects to be deleted. A curl command is used to delete those objects.

Multiple file uploads can be accomplished in a similar manner, using the bulk-upload option.

               
               
               # swift -U swift1 -K swift1 \ -A http://192.168.0.200/v1/export/MyMusic \ upload --object-name a1 Various aa.txt
a1
# swift -U swift1 -K swift1 \ -A http://192.168.0.200/v1/export/MyMusic \ upload --object-name a2 Various aa.txt
a2
# swift -U swift1 -K swift1 \ -A http://192.168.0.200/v1/export/MyMusic \ upload --object-name a3 Various aa.txt
a3
# vi object_to_delete

               
               
               # cat objects_to_delete
Various/a1
Various/a2
Various/a3
# swift -U swift1 -K swift1 \ -A http://192.168.0.200/v1/export/MyMusic/Various list
DabyToure&SkipMcDonald.mp3
a1
a2
a3
aa.txt
# curl -X DELETE -H "X-Auth-Token: $token" \ -T objects_to_delete \ "http://192.168.0.200/v1/export/MyMusic/Various/?bulk-delete"
Number Deleted: 3
Number Not Found: 0
Response Body:
Response Status: 200 OK
Errors:
# swift -U swift1 -K swift1 \ -A http://192.168.0.200/v1/export/MyMusic/Various list
DabyToure&SkipMcDonald.mp3
aa.txt
#