Manage OCI Object Storage — buckets, uploads, PARs, and lifecycle policies.
Use when uploading objects, creating pre-authenticated requests, or configuring lifecycle rules.
Trigger with "oci object storage", "oci bucket", "par url", "multipart upload", "oci lifecycle".
allowed-tools
Read, Write, Edit, Bash(pip:*), Grep
version
1.7.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
["saas","oraclecloud","oci"]
compatibility
Designed for Claude Code
OCI Object Storage — Buckets, PARs & Lifecycle
Overview
Manage OCI Object Storage using the Python SDK. Object Storage is OCI's S3 equivalent, but PAR (Pre-Authenticated Request) URLs expire silently with no error — the URL just returns 404. Multipart uploads over 50GB require manual part management. Lifecycle policies can delete data unexpectedly if misconfigured. This skill covers the safe patterns for all of these operations.
Purpose: Upload, download, and share objects safely with proper PAR expiry management and lifecycle policy configuration.
Prerequisites
OCI Python SDK — pip install oci
Config file at ~/.oci/config with fields: user, fingerprint, tenancy, region, key_file
IAM policy — Allow group Developers to manage objects in compartment <name>
Python 3.8+
Instructions
Step 1: Discover Namespace and Create a Bucket
Every OCI tenancy has a unique Object Storage namespace. You must discover it before any operation.
PARs are OCI's signed URLs. Critical gotcha: expired PARs return 404 NotFound, not 401 or 403. Callers assume the object was deleted when it is actually just the PAR that expired.
# Create a PAR with explicit expiry
par = storage.create_preauthenticated_request(
namespace_name=namespace,
bucket_name="app-data-bucket",
create_preauthenticated_request_details=oci.object_storage.models.CreatePreauthenticatedRequestDetails(
name="partner-download-2026q1",
access_type="ObjectRead",
object_name="reports/2026/report.csv",
time_expires=datetime.utcnow() + timedelta(hours=24),
),
).data
par_url = f"https://objectstorage.{config['region']}.oraclecloud.com{par.access_uri}"print(f"PAR URL (expires in 24h): {par_url}")
print(f"PAR ID (save for revocation): {par.id}")
# List active PARs to audit expiry
pars = storage.list_preauthenticated_requests(
namespace_name=namespace,
bucket_name="app-data-bucket",
).data
for p in pars:
remaining = p.time_expires - datetime.utcnow()
print(f"{p.name} | expires: {p.time_expires} | remaining: {remaining}")
# Revoke a PAR before expiry
storage.delete_preauthenticated_request(
namespace_name=namespace,
bucket_name="app-data-bucket",
par_id=par.id,
)
print("PAR revoked")
Step 5: Configure Lifecycle Policies
Lifecycle rules can auto-archive or delete objects. Warning: A rule with time_amount=30 and action=DELETE will permanently delete objects after 30 days with no recovery unless versioning is enabled.
A versioned Object Storage bucket with no public access
Simple upload for small files and UploadManager for large files (automatic multipart)
PAR URLs with explicit expiry and audit/revocation workflow
Lifecycle policies that archive old data and clean up temp files
Error Handling
Error
Code
Cause
Solution
Bucket not found
404 NotAuthorizedOrNotFound
Wrong namespace, bucket name, or IAM
Verify namespace with get_namespace(), check IAM policy
PAR returns 404
404
PAR expired (not the object)
List PARs to check expiry; create a new PAR
Object too large
400 InvalidParameter
Simple upload > 50MB
Use UploadManager with allow_multipart_uploads=True
Not authenticated
401 NotAuthenticated
Bad API key or config
Verify ~/.oci/config key_file and fingerprint
Rate limited
429 TooManyRequests
Too many API calls
Add backoff; OCI does not return Retry-After header
SSL error
N/A CERTIFICATE_VERIFY_FAILED
Corporate proxy or cert issue
Set SSL_CERT_FILE env var or configure SDK cert bundle
Examples
Quick bucket list via CLI:
oci os bucket list \
--compartment-id <OCID> \
--query "data[*].{Name:name,Versioning:versioning}" \
--output table
Check all active PARs across buckets:
buckets = storage.list_buckets(
namespace_name=namespace,
compartment_id=config["tenancy"],
).data
for b in buckets:
pars = storage.list_preauthenticated_requests(
namespace_name=namespace,
bucket_name=b.name,
).data
if pars:
print(f"\n{b.name}:")
for p in pars:
print(f" {p.name} | expires: {p.time_expires}")
After setting up Object Storage, see oraclecloud-query-transform to monitor storage metrics via MQL, or oraclecloud-schema-migration if you need to export database data into Object Storage buckets.