How to upload files to Object Storage containers from Linux using curl?
You can use Openstack API to upload files, first you have to generate api token with following script:
#!/bin/bash # Example curl for token retrieve. # Change name, domain, password in identity # Change id and domain in project scope # Change url corresponding to OS # If you succeed you will recive x-subject token export OP_TOKEN=$(curl -i \ -H "Content-Type: application/json" \ -d ' { "auth": { "identity": { "methods": ["password"], "password": { "user": { "name": "xxxxxxx@xxxxx.com", "domain": { "name": "cloud_000xx" }, "password": "xxxxxxxxxxx" } } }, "scope": { "project": { "name": "your_project_name", "domain": { "id": "your_domain_id" } } } } }' \ https://cf2.cloudferro.com:5000/v3/auth/tokens | grep Subject-Token | awk '{print $2}')
Domain ID can be found in Domains menu under Identity tab:
Alternativly You can find Domain ID in a OpenStack RC file under OS_PROJECT_DOMAIN_ID variable.
The obtained token will be stored in variable $OP_TOKEN.
Then you can use curl to send file upload request.
You can easily find the address of your Object Store URL in API Access menu:
Save it and proceed to typing in command.
For example:
curl -H 'X-Auth-Token: your_auth_token' Object_Store_API_ACCESS_URL/name_of_your_container
Will list the content of your Object Storage.
To upload a file:
curl -X PUT -i -d "" -H 'X-Auth-Token: your_auth_token' Object_Store_API_ACCESS_URL/name_of_your_container/your_file
v.2019-12-06 15:52