Using presigned URLs in Cloud Object Storage 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 pre-signed URL. Presigned URLs create a temporary link that can be used to share an object publicly. Since 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—the creation of HMAC (Access/Secret key) credentials.
Generate new credential with HMAC
Under Service credentials, click New credential.
Under Add Inline Configuration Parameters, add
Click Add to create.
GET operation written in Python 3.x
Here an example of a basic
GET operation written in Python 3.x. Pass the required request elements before using this code.
Pre-signed URL in the console
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. To experience the proper use of pre-signed URL, try this solution tutorial.