Skip to main content

Package for easy Oci Buckets management in python.

Project description

OCI Bucket Framework

For easier OCI blob manipulation, read, download, etc.

Import

from oci_bucket import OciBucket

Load from Instance Principal

storage_client = OciBucket.client().from_instance_principal()
oci_bucket = OciBucket(storage_client, bucket_name)

Load from OCI Config File

storage_client = OciBucket.client().from_file() # Defaults to ~/.oci/config
oci_bucket = OciBucket(storage_client, bucket_name)

Methods

Note that limit is set to 1000 by default, this limitation comes from original oci.object_storage.ObjectStorageClient.object_list. This lib can go further and handle the pagination for you, just use limit beyond 1000.

files = oci_bucket.list_folder('multiples', limit=12) # retrives files from directory
files = oci_bucket.glob('multiples/1{1,2}0{3,4}.txt', limit=30) # Linux ls pattern can be used for blob filtering.
files = oci_bucket.glob('*audio*wav', limit=30) # Using wildcard '*'
file = oci_bucket.get_file('multiples/0005.txt') # Or just retrieve a specifi file directly

Handling Files in Bucket

oci_bucket.upload_file('acdc.csv', 'csvs') # Upload local file to bucket
oci_bucket.get_file('csvs/acdc.csv').download('local_dir') # Download buckt file to local
oci_bucket.get_file('csvs/acdc.csv').copy('new_csvs') # Copies a file in a bucket to another
oci_bucket.get_file('csvs/acdc.csv').move('new_csvs') # Moves a file in a bucket to another
oci_bucket.get_file('csvs/acdc.csv').delete() # Deletes a file in bucket

Blob Usage

As you can retrieve both a list of files or just a specific one, the blob files have methods on their own.

Load Pandas dataframe Direct From CSV file bytes.

import pandas as pd
from io import BytesIO
file_bytes = oci_bucket.get_file('csvs/acdc.csv').get_bytes()
df = pd.read_csv(BytesIO(file_bytes))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oci_bucket-1.0.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oci_bucket-1.0.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file oci_bucket-1.0.2.tar.gz.

File metadata

  • Download URL: oci_bucket-1.0.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for oci_bucket-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3be76a54cdc5e5e2ba491701a199e9ad8942786a1dcf74ef11f075cc79624746
MD5 28ecd895997dfe166df69bce24469015
BLAKE2b-256 7c665124fc333584c4f977c6d441403a3a24e8e1690cd8e3a7a1cf18e321f97f

See more details on using hashes here.

Provenance

The following attestation bundles were made for oci_bucket-1.0.2.tar.gz:

Publisher: python-publish.yml on dsantiago/oci_bucket

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oci_bucket-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: oci_bucket-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for oci_bucket-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dec1782706d5a412674dcaaffe361065d835d40a9b06ce6d7a4a9d2f840037ba
MD5 9abf5de61cd1e4ad5e89dc19803a14e0
BLAKE2b-256 fd0d6af6212b6da108d26d95c3e9bd233e77cddf214ac78120332cb9c2c198d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for oci_bucket-1.0.2-py3-none-any.whl:

Publisher: python-publish.yml on dsantiago/oci_bucket

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page