Search code examples
ibm-cloudwebsphere-libertyobject-storage

How to make IBM Bluemix Object Storage file publicly accessible?


On Bluemix, I created a Java application using Liberty for Java and the Object Storage Service. I then bound the Java Application and Object Storage Device. I uploaded the images into the container which I created in the Object Storage service. Now I want to access the uploaded images publicly, such as opening the images in a browser directly. I created the URL like the IBM Bluemix documentation said. After I access the URL in browser it shows the following error:

401 Unauthorized

Unauthorized

This server could not verify that you are authorized to access the document you requested.

My sample URL

Is it possible to make the URL public?


Solution

  • You can create a temporary public URL using the swift command line. First you need to set a key and they create the temporary url. For example:

    swift post -m "Temp-URL-Key:yourkey"

    swift tempurl GET 3000 /v1/AUTH_90e12a182adf4a32bbd5e34645380244/offermsgs-cateimgs/books.jpg yourkey

    The output of the command above will be your temporary public URL and in the example below it will be valid for 3000 seconds.

    You can modify Object Storage ACL as well to make all files read only as suggested in the following post:

    Public URLs For Objects In Bluemix Object Storage Service