The OpenStack Swift API is fully supported by 5centsCDN for efficient cloud storage management. To quickly set up and utilize this API, follow the steps provided below and start exploring its extensive features:

  • The first step is to prepare the environment to use the OpenStack API. You need to install the open stack and required software in your system. Click here for more info
  • After the installation, you need to download the OpenStack RC file from the console. Please follow the steps
    1. Log in to the 5centsCDN console.
    2. Go to Zones and select HTTP Push or VoD push zone.
    3. Click the Manage button of your Push zone.
    4. On the redirected page, click FTP / OpenStack Details.
    5. You can download the RC file from the OpenStack RC File option
  • Install Openstack client if needed.
    user@host:~$ pip install python-openstackclient

    You can refer to more details here

  • Set the OpenStack Environment variables.
    user@host:~$ source

    * represents the downloaded RC file.

You can retrieve the list of possible commands

user@host:~$ swift --help

Here is the list of the main commands:

Command Description
delete Deletes a container or objects within a container
download Downloads objects from containers
list Lists the containers for the account or the objects for a container
post Updates meta information for the account, container, or object. If the container is not found, it will be created automatically.
stat Displays information for the account, container, or object.
upload Uploads specified files and directories to the given container.
capabilities Retrieves capability of the proxy.
tempurl Generates a temporary URL for a Swift object.

List Containers

user@host:~$ swift list

List all objects inside a Container

user@host:~$ swift list container_name

Creating a public object container

  • Create the container “container1”:

user@host:~$ swift post container1

  • Configure the access rights to make your container public:
user@host:~$ swift post --header "X-Container-Read: .r:*" container1
  • Check the container configuration:
user@host:~$ swift stat container1

Account: AUTH_b3e26xxxxxxxxxxxxxxxxxxxb0ba29
Container: container1
Objects: 0
Bytes: 0
Read ACL: .r:*
Write ACL:
Sync To:
Sync Key:
Accept-Ranges: bytes
X-Trans-Id: B2210C05:8D93_052711A1:01BB_561CC9DF_1B305:30D7
X-Storage-Policy: Policy-0
Connection: close
X-Timestamp: 1444726875.27475
Content-Type: text/plain; charset=utf-8

Uploading files to your container

  • Upload the content of a local folder to a container:
user@host:~$ swift upload container1 images/


A prefix will automatically be added to your files if you send an entire folder instead of a single file.

  • List a container’s files:
user@host:~$ swift list container1


You can display all files with a particular prefix using the –prefix argument:

user@host:~$ swift list container1 --prefix images


Downloading files

  • Download a file:
user@host:~$ swift download container1 text1.txt

text1.txt [auth 0.328s, headers 0.452s, total 0.453s, 0.000 MB/s]

You can download multiple files with the same prefix, using the following command:

user@host:~$ swift download container1 --prefix images

images/img1.png [auth 0.383s, headers 0.520s, total 0.522s, 0.135 MB/s]
images/img2.jpg [auth 0.371s, headers 0.514s, total 0.559s, 2.657 MB/s]

Deleting containers or objects

  • Delete a file:
user@host:~$ swift delete container1 text1.txt


As with downloading, you can delete multiple files using the same prefix, with the following command:

user@host:~$ swift delete container1 images/*

  • Delete a container:
user@host:~$ swift delete container1


You can refer to this video tutorial for more info

Leave a Reply