Create a presigned URL to download an object in Python 3.x
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
- 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