Skip to main content

Swift Object Storage

OpenStack Object Storage (Swift)

This guide explains how to manage Object Storage using the OpenStack CLI. It applies to OpenStack Swift environments.


Prerequisites

Some Swift operations require an extra client.

pip install python-swiftclient

Make sure your OpenStack credentials are loaded (for example, using an openrc file).

Create a Container

A container is the main storage unit in Swift.

Create a container named data:

openstack container create data

Download an object.

To download an object locally:

openstack object save data test/example.png \
--file local-file.png

Delete a Container

If you want to delete the container, you can use the following command:

openstack container delete data

List Containers

To list all containers in your project:

openstack container list
+-------------+
| Name |
+-------------+
| data |
+-------------+

Upload Objects

You can upload files to a container using the OpenStack client. Object names can include path-like prefixes.

openstack object create data \
--name test/example.png \
./example.png
+------------------------------------+--------------+----------------------------------+
| object | container | etag |
+------------------------------------+--------------+----------------------------------+
| test/example.png | data | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+------------------------------------+--------------+----------------------------------+

List Objects in a Container

openstack object list data
+------------------------------------+
| Name |
+------------------------------------+
| test/example.png |
+------------------------------------+

Container Usage

To see how much storage are you using in your container, use the following commnand:

openstack container show data
+----------------+-------------------+
| Field | Value |
+----------------+-------------------+
| container | data |
| bytes_used | 3045 |
| object_count | 1 |
| storage_policy | default-placement |
+----------------+-------------------+