X

Break New Ground

Working with Oracle Cloud Infrastructure Object Storage

In this post, you’ll learn about the Oracle Cloud Infrastructure Object Storage service, how to create an object storage bucket, and how to upload a simple HTML page to it.

Object Storage

With Object Storage, you can store or retrieve data directly from the internet or within the cloud platform. Object Storage stores and manages data as objects that are organized into buckets. Each object has a set of metadata that describes the object.

Figure 1: Object Storage

 

The data stored in the object storage isn’t tied to any compute instance and can be accessed and used anywhere.

When you create a storage bucket, you can choose from the following storage tiers:

  • Standard tier: Used for data to which you need fast, immediate, and frequent access
  • Archive tier: Appropriate for rarely accessed data and data that you have to retain for a longer time

Object events

For scenarios in which you want the Object Storage to automatically emit events on changes, you can enable the option of emitting events. You can respond to events and create automation based on the state changes of the resources. Events are structured messages that follow the CloudEvents industry-standard format. For more information about events, see Overview of Events.

The events in object storage are emitted on two levels; the object level and the bucket level. You can respond to events when buckets or objects are created, deleted, or updated.

For a detailed overview of all events, refer to Object Storage events.

Object versioning

You can optionally enable object versioning on your Object Storage resources. Object versioning provides data protection against accidental or malicious object updates, overwrites, or deletions. When versioning is enabled, a new version of an object is created whenever a new object is uploaded, an existing object is overwritten, or an object is deleted.

Read more about object versioning in Using Object Versioning.

Create an Object Storage bucket

Let’s create a storage bucket in the Console to host a simple HTML page.

  1. Open the navigation menu, select Object Storage, and then select Object Storage.
  2. Click the Create Bucket.
  3. Name the bucket public-website.
  4. Select the Standard storage tier.
  5. Leave both Object Events and Object Versioning unselected.
  6. Click Create Bucket.
  7. On the Buckets page, click the name of the bucket to open its details page. The page should look like the one shown in the following figure.
Figure 2: Created bucket

 

Change the bucket’s visibility

By default, the buckets are considered a private bucket, and the access to the contents requires authentication and authorization. However, Object Storage supports anonymous, unauthenticated access to a bucket that isn’t in a security zone.

Because we want to host an HTML page and make it publicly accessible, we have to change the bucket visibility from private to public.

Anything uploaded to a public bucket is available for anyone to access. Even if you prevent users from listing objects from the bucket, they can access the object if they know the file name.

To change the bucket visibility:

  1. On the bucket’s details page, click Edit Visibility.
  2. In the dialog box, select Public.
  3. Clear the Allow users to list objects from this bucket checkbox. We want users to access the HTML file but not to list the contents of the bucket.
  4. Click Save Changes.
Figure 3: Bucket visibility

 

Create and upload an HTML file

Let’s create a file called index.html with the following contents:

<!DOCTYPE html>
<html>
  <head>
    <title>Hello from Storage Bucket!</title>  
  <head>
  <body>
    Hello from my Storage Bucket!
  </body>
<html>

Next, we upload this file as an object to the public-website bucket that we created earlier. Because the bucket’s visibility is set to public, we can access the index.html page directly from a URL.

To upload the file:

  1. On the bucket details page, in the Objects section, click Upload.

  2. Drag the index.html file into the section of the Upload Objects dialog box that says Drop files here.

    Alternatively, you can click Select files and use the browser dialog box to upload the file.

  3. Click Upload to upload the file.

  4. After the file is uploaded, you can click Close. The uploaded file is displayed in the list of objects, as shown in the figure below.

Figure 4: A screenshot that shows the bucket details page with the index.html file listed under Objects

 

Access the HTML page from a URL

Each object in the bucket can be accessed through a URL.

  1. To get the URL for the object, open the context menu (three dots) and select View Object Details.
Figure 5: View object details

 

  1. In the Object Details dialog box, click the URL Path to open the uploaded object. Because the uploaded object is an HTML file, it’s opened in a browser, as shown in the following figure.
Figure 6: index.html page

 

Lifecycle policies

Another useful feature of the Object Storage service is defining lifecycle policies. Earlier we mentioned the two tiers of Object Storage: standard and archive. With a lifecycle policy, you can create rules that will either archive or delete the objects older than the specified number of days.

For example, you can create a rule that archives all PNG files older than 10 days. Here’s how you could do that:

  1. From the Resources list on the bucket’s details page, select Lifecycle Policy Rules.
  2. Click Create Rule.
  3. Configure the lifecycle rule as follows:
    1. Enter a name, for example, delete-images.
    2. Select Objects as the target.
    3. Select Archive as the lifecycle action.
    4. Enter 10 for the number of days.
    5. Click Add Filter, choose Include by pattern, and enter *.png. If you don’t create any filter, the rule applies to all the objects in the bucket.
  4. Click Create.
Figure 7: Lifecycle rule

 

A lifecycle policy scenario in which you delete the objects would be if you’re creating temporary data as part of your logic - for example, creating reports that users can download. After users download the report, the data is not needed anymore. Using a lifecycle policy, you could keep it in the bucket for a couple of days and then delete it.

Read more about lifecycle management in Using Object Lifecycle Management.

Conclusion

In this post, you learned about object storage. You saw how to create new buckets, upload objects, make buckets public, and access objects through a URL. You have also learned about lifecycle policies and how to create policies that archive or delete objects, based on rules.

In an upcoming blog post, we’ll show you how to secure Oracle Cloud Infrastructure object storage buckets by using Identity and Access Management (IAM) policies.

Resources


Every use case is different. The only way to know if Oracle Cloud Infrastructure is right for you is to try it. You can select either the Oracle Cloud Free Tier or a 30-day free trial, which includes US$300 in credit to get you started with a range of services, including compute, storage, and networking.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.