Temporary URL to access objects in Object Storage in IBM Bluemix using Python Swift Client

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.

 Prerequisites:

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.

                   export OS_USER_ID=<user_id>

                   export OS_PASSWORD=<password>

                   export OS_PROJECT_ID=<project_id>

                   export OS_AUTH_URL=https://identity.open.softlayer.com/v3

                   export OS_REGION_NAME=dallas

                   export OS_IDENTITY_API_VERSION=3

                   export OS_AUTH_VERSION=3

(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/

Advertisements

Watson powered Slackbot that helps you with language translation

Have you ever got lost in a new city not knowing the language or have you got stuck with your French/Spanish classes/homework? This simple Slackbot powered by Watson Conversation and Language Translator, translates language and helps you understand them faster & better by conversing!

imageIt is a simple Slackbot that can translate from English to French, French to English and Spanish to English(more translations are possible since Watson Language Translator supports Arabic,French,Spanish and Portugese). The Slackbot identifies the intent of natural language input through Watson Conversation and responds with the translated language.

Steps to build this Slackbot is available here http://bit.ly/2lM5hye

Hashtag sentiment Analyzer using Node-RED,Cloudant, dashDB,R script

2

Twitter Node Configuration:7

Switch Node Configuration:

3

Not so positive function node configuration:

4

Positive sentiment Function Node configuration:

5

Cloudant Node Configuration:

6

Once after wiring the nodes, click on DEPLOY ( top right corner of Node-RED).

Launch Cloudant and then you will find your database in the list

8

Create a dashDB warehouse to graphically analyze the sentiment

9

Goto dashDB and then run R script

10

Rscript.PNG

Data has been graphically analyzed using R Scripts.

1

1 represents Positive sentiment and 0 represents not-so-Positive sentiment