You can manage your CDN Storage container through Swift API. You can list all containers in your account, list all the objects in a container, upload, download, and delete resources.
First, you need to obtain the “StorageURL” and the “Auth Token” for your account by using the following command:
swift stat --verbose --os-username YOUR_USERNAME --os-tenant-name YOUR_TENANT --os-password YOUR_PASSWORD --os-auth-url
Example:
swift stat --verbose --os-username 1011131 --os-tenant-name 1011131 --os-password fQFImBsSeaJjicts --os-auth-url https://auth.files.us01.cloud.servers.com:5000/v3 --auth-version 3
Example output:
Storage URL: https://storage.files.us01.cloud.servers.com:8080/v1/SERVERSCOM_50d9a8b35b5a4bb4a80957fb52ab363c Auth Token: 09d6383b9aha5c6zb657c8affb897g48 Account: SERVERSCOM_50d7b9h54b5a4bb4a87947fj52ab363c Containers: 2 Objects: 4 Bytes: 32364740 Containers in policy “policy-0”: 2 Objects in policy “policy-0”: 4 Bytes in policy “policy-0”: 32364740 Meta Temp-Url-Key: TinNbwQgxIBmodufCWdMoueqYWPVtXvL X-Account-Project-Domain-Id: _unknown X-Openstack-Request-Id: tx27f229ec643e4f34ac8d3-0060c3454d X-Timestamp: 1572600177.96722 X-Trans-Id: tx27f229ec643e4f34ac8d3-0060c3454d Content-Type: application/json; charset=utf-8 Accept-Ranges: bytes |
The token is valid for 24 hours from generation time.
For information about installing and using the python-swiftclient tool please click here!
Where:
--os-username
Is the first part is your Openstack Swift username (–os-username) and the second part is your Openstack Swift tenant-name (–os-tenant-name) (e.g 1011131.1011131).
Due to the requirements of the Object Storage service (swift) architecture, your FTP username contains two authentication parts separated by dot (.) character.
In the provided example the Openstack Swift username (–os-username) is 1011131
--os-tenant-name
Is the second part of your FTP username is (–os-tenant-name).
In the provided example the Openstack Swift tenant-name (–os-tenant-name) is 1011131
--os-password
Is the FTP password, which can be obtained through the Universal CDN Control Panel.
--os-auth-url
Is the Swift authorization URL.
Below are the authorization URLs that should be used:
https://auth.files.nl01.cloud.servers.com:5000/v3 --auth-version 3
– to connect to your Europe container.
https://auth.files.us01.cloud.servers.com:5000/v3 --auth-version 3
– to connect to your North American container.
IMPORTANT! Be advised that the authentication version (--auth-version 3
) must be specified as well.
Managing Universal CDN Storage with OpenStack Swift API using cURL.
It is a well known command-line tool for transferring data to and from a server. Please review the following examples of some of the allowed operations that can be done with the OpenStack Swift API using cURL:
List all containers in an account:
$ curl -X GET -H 'X-Auth-Token: 09d6383b9aha5c6zb657c8affb897g48' https://storage.files.us01.cloud.servers.com:8080/v1/SERVERSCOM_50d9a8b35b5a4bb4a80957fb52ab363c
List all the objects in a container:
$ curl -X GET -H 'X-Auth-Token: 09d6383b9aha5c6zb657c8affb897g48' https://storage.files.us01.cloud.servers.com:8080/v1/SERVERSCOM_50d9a8b35b5a4bb4a80957fb52ab363c/your_storage_conatainer_name
Upload an object:
$ curl -X GET -H 'X-Auth-Token: 09d6383b9aha5c6zb657c8affb897g48' https://storage.files.us01.cloud.servers.com:8080/v1/SERVERSCOM_50d9a8b35b5a4bb4a80957fb52ab363c/your_storage_conatainer_name/ -T your_file.mp4
Download an object:
curl -X GET -H 'X-Auth-Token: 09d6383b9aha5c6zb657c8affb897g48' https://storage.files.us01.cloud.servers.com:8080/v1/SERVERSCOM_50d9a8b35b5a4bb4a80957fb52ab363c/your_storage_container/your_file.mp4 --output your_file.mp4
Delete an object:
curl -X DELETE -H 'X-Auth-Token: 09d6383b9aha5c6zb657c8affb897g48' https://storage.files.us01.cloud.servers.com:8080/v1/SERVERSCOM_50d9a8b35b5a4bb4a80957fb52ab363c/your_storage_container/your_file.mp4
IMPORTANT! Please note that the storage containers must be created only from the Universal CDN Control Panel. Storage containers created not from the Control Panel will be rejected by the CDN system.
Upload with Python-Swiftclient