In my previous post, Creating an Object Storage Bucket in Oracle Cloud, I introduced Object Storage in Oracle Cloud and I outlined how you can very easily create an object storage bucket.
As a reminder, in Oracle Cloud, object storage is used to store and manage data as objects, providing a reliable, secure and scalable service. OCI Object storage uses “buckets” as a method of organizing the objects (or files). Ultimately, you can think of a bucket as a container that stores –ideally related– objects within an Oracle Cloud compartment (see Creating a Compartment in Oracle Cloud) within a namespace.
A bucket can only be associated to a single compartment and it’s possible to set policies against the compartment & bucket which define the actions/permissions that a user or group have to manipulate the bucket and the objects in the bucket.
There are many use cases in which you might want or need to access an Oracle object storage bucket, in this post, I will explain how you can access objects within your bucket using a pre-authenticated request. Look out for a future post on accessing object storage buckets with granted user permissions.
Create a Pre-Authenticated Request
A pre-authenticated request to access an object storage bucket is a preformed web link, including authorization, which can be sent to someone so that they can access the object from their browser. To create a pre-authenticated request, follow these steps:
Step 1: Log into your Oracle Cloud account (free tier is suitable)
Step 2: Click on the menu icon (often referred to as “Hamburger” or “Pancake Stack” icon)
Step 3: Select “Storage” and then Select “Buckets”
Step 4: You will be presented with the Bucket management screen. Select the compartment in which your object storage bucket resides. (If you haven’t got any compartments and you don’t want to use your root compartment, take a look at my post: Creating a Compartment in Oracle Cloud, if you haven’t created an object storage bucket yet, take a look at my post: Creating an Object Storage Bucket in Oracle Cloud).
Step 5: Click the “3 dots” icon next to the bucket that you wish to create an pre-authenticated request for and click “Create Pre-Authenticated Request”
Step 6: Provide basic information for the pre-authenticated request and click “Create Pre-Authenticated Request”.
Here I am choosing only to provide access to a specific object but there are options to create a pre-authenticated request for the entire bucket or to objects with a specific prefix. In addition, you can selected the request’s permissions to read, write or read and write on the object and set an expiration date for the pre-authenticated request. Once the expiration date is passed, it will not be possible to use this URL.
Step 7: As this is a one-time request, it will not be available to view once the dialog shown below is closed. Make sure that you copy the URL presented by highlighting and copying the text or by clicking the copy button beside the link. Once you have copied the URL, click “Close” to close the dialog
Using a Pre-Authenticated Request
Once you have created your pre-authenticated request using the above steps, you can now access it using the link that you copied in the final step mentioned.
Via a Browser
Step 1: Open your browser of choice
Step 2: Paste your pre-authenticated request URL (see step 7 in the creation of a pre-authenticated request) into the URL bar
Step 3: Click enter on your keyboard to navigate to this URL and you will be presented with the contents of your file
Via Postman (or any other REST API capable tooling)
Step 1: Open Postman and click the “+” icon to create a new request
Step 2: Paste your pre-authenticated request URL (see step 7 in the creation of a pre-authenticated request) into the URL bar. As I am retrieving an object, the HTTP method is “GET”. There is no need to add authentication details as this is a pre-authenticated request and the access token forms part of the URL.
Note 1: The details in this post assume that you already have an Oracle Cloud free tier (or upgraded!) account. If you don’t you can get one here.
Note 2: Given the regular release schedule present in Oracle Cloud, it is possible that the screens may change somewhat beyond the writing of this post. If this happens, please comment on this post and I will try to help you out. (and update this post!)