The Object Storage service is based on OpenStack Swift and can be accessed by using any compatible client application (CloudBerry/CyberDuck/Python Swift Client).
This blog describes how to create a temporary URL to access files/objects in the Object Storage using Python Swift Client without requiring further authentication.
Install Python 2.7 or later(currently it doesn’t support Python 3.0)
Install setuptools on Windows by following the documentation provided on the setuptools website (https://pypi.python.org/pypi/setuptools) For MAC, it is pre-installed
- Ensure that the C:\Python27\Scripts directory is defined in the PATH environment variable, and use the easy_install command from the setuptools package: C:\>easy_install pip
- Install the Python Swift client by using Python pip: sudo pip install python-swiftclient
- Install the Python Keystone client by running the following command: sudo pip install python-keystoneclient
- Next step is setting up the client:
The Swift client takes the authentication information from the following environment variables:
Set the authentication information as follows.
(You can find the <user_id>,<password>,<project_id> for your Object Storage service from the Service Credentials page in the Object Storage user interface in Bluemix Dashboard)
- After that, Identify your authentication account by Swift stat command : swift stat
(Locate the Account field and note the full string behind Account: including AUTH_)
- Set a secret key by typing the command: swift post -m “Temp-URL-Key:<key>”
Ex: swift post -m “Temp-URL-Key:10908765432”
This key can be anything (a long, random, and hard to guess string is preferred)
Run the Swift stat command to verify that the Temp-URL-Key is set successfully: swift stat
- Create the temporary URL using the command: swift tempurl GET <seconds> <path> <key>
Ex: swift tempurl GET 360 /v1/AUTH_e7ddd86303d940ff8372938c41169925/store1/bookshelf.jpg 10908765432
GET allows download. PUT allows upload.
Time in seconds that the temporary URL will be available.
The full path of the object expressed as /v1/<auth_account>/<container_name>/<object_name> (auth_account is the detail, you had got after swift stat command)
The key that you set in the previous step.
- This command will return a URL.
Eg of URL: /v1/AUTH_e7ddd86303d940ff8372938c41169925/store1/bookshelf.jpg?temp_url_sig=92633b82c0f92d91923088aaa5cb22af29e979bf&temp_url_expires=1475489383
- Append the URL to the region you use Object Storage and then use the full URL to download the object with any compatible HTTP client such as curl, wget or Firefox
If it’s DALLAS region, https://dal.objectstorage.open.softlayer.com/
& if it’s London region, https://lon.objectstorage.open.softlayer.com/