Skip to content

LAB 17 ‐ Object Storage: API Connectivity & Compute

DevWithNehaCloud edited this page May 6, 2026 · 11 revisions

Object Storage: API Connectivity using Compute (OCI CLI)

Overview

Object Storage in Oracle Cloud Infrastructure (OCI) can be accessed not only via the Console but also programmatically using API/CLI from a Compute instance.

This approach is commonly used to upload backups, logs, or application data directly from servers to Object Storage.


Concept

In this method:

  • A Compute Instance is used as a client
  • Data is prepared on the server (e.g., compressed using .tar or .zip)
  • OCI CLI (API-based) is used to upload data
  • Data is stored in Object Storage bucket

Architecture Flow

Compute Instance (Server) ↓ Prepare File (tar/zip) ↓ OCI CLI (API Call) ↓ Object Storage Bucket


Real-Time Use Case

Backup Upload using CLI

  • Login to Compute instance using PuTTY
  • Convert data into archive file:

tar -cvf backup.tar /data

  • Use OCI CLI to upload:

oci os object put --bucket-name my-bucket --file backup.tar

➡️ Backup is uploaded to Object Storage using API connectivity


Key Components

  • Compute Instance → Source of data
  • OCI CLI → Acts as API interface
  • Object Storage Bucket → Destination
  • Archive File (.tar/.zip) → Backup format

Why Use API/CLI Instead of Console?

  • Automation (cron jobs, scripts)
  • Faster for large data transfers
  • No manual intervention required
  • Suitable for production environments

Example Scenario

You have application data on a server:

  • Compress data into backup.tar
  • Use CLI to upload to bucket
  • Schedule daily backup using cron

Benefits

  • Automated backups
  • Secure API-based transfer
  • Scalable storage
  • No manual upload required

Summary

Object Storage API connectivity using OCI CLI allows Compute instances to directly upload data to buckets, making it ideal for automated backups and real-time data transfer in production environments.

👉 “We can use OCI CLI from a compute instance to upload backup files to Object Storage using API calls, which helps in automation and real-time data transfer.”

image

Steps to connect Object storage with compute

In below screen, we want to upload scripts file to bucket. so, first we have to convert this file in .tar format(we have created a file scripts and inside that we have a file called random.txt)

image

Now first we convert the scripts folder to tar(zip) folder before sending to the object storage by using the below command.

tar -cvf scripts05052026.tar scripts

In the screen below, you will find four tar files, which serve as backups for the scripts.

image

Run this command to send file to bucket(here bucket name should be same as you have given in console ex. Test-bucket in my case)

oci os object put -bn Test-bucket --file scripts05052026.tar

However, we can observe an error indicating that the OCI command is not found.

image

Step 2 : Download OCI cli package

Run below command to download OCI cli package

a)install Python 3 if not already installed:

sudo dnf install python3

press y to begin the installation

image image

b)Install pip (Python package installer):

sudo dnf install python3-pip

press y to begin the installation

image

c)Install OCI CLI using pip:

python3 -m pip install oci-cli --upgrade
image

The OCI cli package has been successfully downloaded.

d)Verify the version:

oci --version
image

Again Run below command to send file in bucket

oci os object put -bn Test-bucket --file scripts05052026.tar
image

Say no to creating through browser.

We will create through CLI.

Always enter default location to save config file

Enter user's OCID

image image image

Enter tenancy's OCID

image image image

Enter default in below screen

write **default password (N/A) **

image

Open .oci folder

view config file using cat command

Ensure that all the details are accurate and match what you initially entered while creating the configuration file.

image image

Use the cat command to view the API public key and copy it into Notepad for later use.

image

Step 3 : Setting Up API Key for OCI User

Now in OCI console navigate to the user section within the default domain under Identity & Security

image image image image image image

The following screen will appear after adding the API key

You can now verify that all the details in the tab match the ones we entered while creating the configuration file in putty

image image

The bucket is now successfully linked to the instance, allowing us to transfer the backup from the instance to the bucket.

Run below command to transfer file to bucket

oci os object put -bn Test-bucket --file scripts01012025.tar
image

As the user was an administrator, I had already created a policy to manage all resources in the tenancy.

However, if you encounter an error while uploading a file, it might be due to a lack of permissions. To address this, we created a policy that allows the user/group to manage objects in Compartment.

allow service objectstorage-us-ashburn-1 to manage object-family in compartment hub-compute-and-storage-compartment where target.bucket.name = 'Test-bucket'

Now as we can see, file is transferred in bucket successfully.

image

Clone this wiki locally