Manage objects and containers The OpenStack Object Storage service provides the swift client, which is a command-line interface (CLI). Use this client to list objects and containers, upload objects to containers, and download or delete objects from containers. You can also gather statistics and update metadata for accounts, containers, and objects. This client is based on the native swift client library, client.py, which seamlessly re-authenticates if the current token expires during processing, retries operations multiple times, and provides a processing concurrency of 10.
Create and manage containers To create a container, run the following command and replace CONTAINER with the name of your container. $ swift post CONTAINER To list all containers, run the following command: $ swift list To check the status of containers, run the following command: $ swift stat Account: AUTH_7b5970fbe7724bf9b74c245e77c03bcg Containers: 2 Objects: 3 Bytes: 268826 Accept-Ranges: bytes X-Timestamp: 1392683866.17952 Content-Type: text/plain; charset=utf-8 You can also use the swift stat command with the ACCOUNT or CONTAINER names as parameters. $ swift stat CONTAINER Account: AUTH_7b5970fbe7724bf9b74c245e77c03bcg Container: storage1 Objects: 2 Bytes: 240221 Read ACL: Write ACL: Sync To: Sync Key: Accept-Ranges: bytes X-Timestamp: 1392683866.20180 Content-Type: text/plain; charset=utf-8
Manage access Users have roles on accounts. For example, a user with the admin role has full access to all containers and objects in an account. You can set access control lists (ACLs) at the container level and support lists for read and write access, which you set with the X-Container-Read and X-Container-Write headers. To give a user read access, use the swift post command with the -r parameter. To give a user write access, use the -w parameter. The following example enables the testuser user to read objects in the container: $ swift post -r 'testuser' You can also use this command with a list of users. If you use StaticWeb middleware to enable Object Storage to serve public web content, use .r:, followed by a list of allowed referrers. The following command gives object access to all referring domains: $ swift post -r '.r:*'
Manage objects To upload an object to a container, run the following command: $ swift upload CONTAINER OBJECT_FILENAME To upload in chunks, for large files, run the following command: $ swift upload -S CHUNK_SIZE CONTAINER OBJECT_FILENAME To check the status of the object, run the following command: $ swift stat CONTAINER OBJECT_FILENAME Account: AUTH_7b5970fbe7724bf9b74c245e77c03bcg Container: storage1 Object: images Content Type: application/octet-stream Content Length: 211616 Last Modified: Tue, 18 Feb 2014 00:40:36 GMT ETag: 82169623d55158f70a0d720f238ec3ef Meta Orig-Filename: images.jpg Accept-Ranges: bytes X-Timestamp: 1392684036.33306 To list the objects in a container, run the following command: $ swift list CONTAINER To download an object from a container, run the following command: $ swift download CONTAINER OBJECT_FILENAME