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
tar -cvf scripts01012024.tar scripts
"In the screen below, you will find four tar files, which serve as backups for the scripts."
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."
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
b)Install pip (Python package installer):
sudo dnf install python3-pip
write y to begin the installation
c)Install OCI CLI using pip:
python3 -m pip install oci-cli --upgrade
The OCI cli package has been successfully downloaded.
d)Verify the installation:
oci --version
Again Run below command to send file in bucket
oci os object put -bn Test-bucket --file scripts01012025.tar
Say no to creating through browser.
We will create through CLI.
-
Always enter default location to save config file
-
Enter user's OCID
- Enter tenancy's OCID
- Enter region's name
-
Enter default in below screen
-
write **default password (N/A) **
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.
Use the cat command to view the API public key and copy it into Notepad for later use.
Step 3 : Setting Up API Key for OCI User
Navigate to the user section within the default domain under Identity & Security
Open the user profile, scroll down, and click on Add API Keys under the API Keys section
Paste the public key that we previously saved in Notepad, and click on Add
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
"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
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'
Now try to send file again to bucket,
As we can see, file is transferred in bucket successfully.