Presigned URLs in Cloud Object Storage create a temporary link that can be used to share an object publicly for direct download.

In one of my serverless(IBM Cloud Functions) proof of concepts, I had an idea of creating a presigned url. As all my actions are written in Python 3.x, I decided to automate the presigned URL creation. Before migrating the Python 2.x code provided in the link here, I realised that there is one more additional step needed i.e., creation of HMAC (Access/Secret key) credentials.

To generate new credential with HMAC,

  • Navigate to your Cloud Object Storage service on your IBM Cloud dashboard and under Service credentials, click New credential.
  • Under Add Inline Configuration Parameters, add
{“HMAC”:true}
  • Click Add to create.

Here an example for basic GET operation written in Python 3.x

Pass the required request elements before using this code

Once you pass the required elements in the placeholders provided and execute the code. You should see your pre-signed url in the console.

You can set the expiration time in seconds

vmacwrites

Tech writings by Vidyasagar Machupalli

Vidyasagar Machupalli

Written by

Developer, IBMer, Speaker, Blogger, Teetotaller, Geek & many more…

vmacwrites

Tech writings by Vidyasagar Machupalli

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade