16. Object Storage: API Connectivity & Compute - Ayushi-srivastav/OCI GitHub Wiki

Steps to connect Object storage with compute

Step 1 : Convert file in zip

In below screen, we want to upload scripts file to bucket. so, first we have to convert this file in .tar format

image

tar -cvf scripts01012024.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

oci os object put -bn Test-bucket --file scripts01012025.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

write y to begin the installation

image

b)Install pip (Python package installer):

sudo dnf install python3-pip

write 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 installation:

oci --version

image

Again Run below command to send file in bucket

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

image

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 region's name

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

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

Navigate to the user section within the default domain under Identity & Security

image

Open the user profile, scroll down, and click on Add API Keys under the API Keys section

image

Paste the public key that we previously saved in Notepad, and click on Add

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

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 computecomp where target.bucket.name = 'Test-bucket'

image

Now try to send file again to bucket,

As we can see, file is transferred in bucket successfully.

image