{"library":"ocifs","title":"Oracle Cloud Infrastructure Filesystem (ocifs)","description":"ocifs is a Pythonic filesystem interface to Oracle Cloud Infrastructure (OCI) Object Storage. It builds on top of the `oci` Python SDK and integrates with the `fsspec` (filesystem_spec) ecosystem, allowing applications to interact with OCI Object Storage as if it were a local filesystem. It provides common file-system style operations like `cp`, `mv`, `ls`, `du`, and `open()` for reading and writing data. The current version is 1.3.4, and it is actively maintained by Oracle with a regular release cadence.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install ocifs"],"cli":null},"imports":["from ocifs import OCIFileSystem"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import ocifs\nimport os\n\n# Initialize OCIFileSystem.\n# It will attempt to use default OCI config (~/.oci/config) or Resource Principal/Instance Principal.\n# For explicit config, pass a path or an oci.config object.\n# config_path = os.environ.get('OCI_CONFIG_PATH', '~/.oci/config')\n# fs = ocifs.OCIFileSystem(config=config_path, profile=os.environ.get('OCI_PROFILE', 'DEFAULT'))\n\nfs = ocifs.OCIFileSystem()\n\n# Replace with your bucket and namespace\nbucket_name = 'your_bucket_name'\nnamespace_name = 'your_namespace_name'\n\n# List contents of a bucket\ntry:\n    print(f\"Listing contents of oci://{bucket_name}@{namespace_name}\")\n    items = fs.ls(f'oci://{bucket_name}@{namespace_name}')\n    for item in items:\n        print(item)\nexcept Exception as e:\n    print(f\"Error listing bucket contents: {e}\")\n\n# Example: Write and read a file\nfile_path = f'oci://{bucket_name}@{namespace_name}/test_ocifs.txt'\ndata_to_write = b'Hello, ocifs!'\n\ntry:\n    with fs.open(file_path, 'wb') as f:\n        f.write(data_to_write)\n    print(f\"Successfully wrote to {file_path}\")\n\n    with fs.open(file_path, 'rb') as f:\n        read_data = f.read()\n    print(f\"Successfully read from {file_path}: {read_data}\")\n    assert read_data == data_to_write\n\n    fs.rm(file_path)\n    print(f\"Successfully deleted {file_path}\")\nexcept Exception as e:\n    print(f\"Error during file operations: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize `OCIFileSystem` and perform basic operations like listing objects, writing, and reading a binary file from Oracle Cloud Object Storage. It assumes OCI credentials are configured via a default `~/.oci/config` file or available through Resource/Instance Principals. Remember to replace placeholder bucket and namespace names.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}