IBM Object Storage, like Amazon S3, enables storage and retrieval of any amount of data from anywhere on the web. Customers use it as a bulk repository, or “data lake,” for analytics, backup & recovery, disaster recovery, and serverless computing. Many cloud-native applications even use it as primary storage, like IBM’s Data Science Experience.

One drawback for some users, however, is that IBM Object Storage out-of-the-box doesn’t provide public, unauthenticated access to files. I created an app that fills the gap by providing a RESTful interface to the data in Object Storage.

My open object store sample app is a drop-in facade on top of any Object Storage instance that allows easy data publishing in an interoperable, RESTful manner. Get the code on GitHub.

How it works

This Python Flask web app conforms to RESTful principles of exposing data on the Internet and provides:

  1. a single entry URL from which all data resources can be accessed via stateless URL traversal.
  2. read-only access to these data resources via HTTP GET.

What the app doesn’t do is implement a full CRUD service, which would allow resources to be created and updated. If that’s important to you, feel free to pitch in. Pull requests on the repo are welcome!

Many links in this article open JSON documents, which are much easier to read and parse when viewed with syntax highlighing. We recommend installing one of these simple browser add-ons:

To see my demo, go to the entry URL, http://openobjectstore.mybluemix.net/. The service returns a JSON document. It contains one field, containers, which holds an array of metadata about container objects, which correspond to the containers in the Object Store service instance.

Endpoint request (lists containers)
https://openobjectstore.mybluemix.net

Endpoint response (partial listing)

{
    "containers": [{
        "accessURL": "https://openobjectstore.mybluemix.net/BostonCodeCamp",
        "name": "BostonCodeCamp",
        "bytes": 0,
        "objects": 0
    }, {
        "accessURL": "https://openobjectstore.mybluemix.net/Election",
        "name": "Election",
        "bytes": 15141442,
        "objects": 11
    }, {
        "accessURL": "https://openobjectstore.mybluemix.net/censusacs2014",
        "name": "censusacs2014",
        "bytes": 119424774,
        "objects": 11
    }]
}

Each container object has an accessURL property. Accessing that URL makes another stateless call to the service, appending the container name to the entry URL, which returns a JSON document comprised of all the objects in that container. For example try:

Container request (lists objects)
https://openobjectstore.mybluemix.net/censusacs2014

Container response (partial listing)

{
  "objects": [
    {
      "downloadURL": "https://openobjectstore.mybluemix.net/censusacs2014/x01_age_sex.csv",
      "last_modified": "2016-11-11T18:25:54.822290",
      "name": "x01_age_sex.csv",
      "content_type": "text/csv",
      "bytes": 3909967
    },
    {
      "downloadURL": "https://openobjectstore.mybluemix.net/censusacs2014/x02_race.csv",
      "last_modified": "2016-11-11T18:26:22.645450",
      "name": "x02_race.csv",
      "content_type": "text/csv",
      "bytes": 1070001
    }
  ]
}

Here you get some basic metadata about the objects, including name, size in bytes, MIME type (content_type), and downloadURL, which gives the client (machine or human) HTTP GET access to the data. All this without writing a single line of metadata by hand.

Rolling your own service

To try it yourself, click the following Deploy to Bluemix button, which will:

  • create an instance of IBM Object Storage for you
  • create a Python runtime with this Flask app deployed
  • hook them both together and deploy the service on the web

For more details (including deployment instructions for local development), head over to the openobjectstore GitHub repo and follow the steps in the README.

Deploy to Bluemix

If you don’t already have a Bluemix account, you’ll be prompted to sign up for a free trial. Once the app deploys, all you need to do is load up your Object Storage with data and start making calls.

Join The Discussion

Your email address will not be published. Required fields are marked *