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.
pip install ocifsVerified import paths — ran on the pinned version, not inferred.
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.
Provide `config` (path to `~/.oci/config` or `oci.config` object) and `profile` arguments, or pass an authenticated `signer` object to `OCIFileSystem` for clarity and control. For example: `fs = ocifs.OCIFileSystem(config='~/.oci/config', profile='MY_PROFILE')` or `from oci.auth.signers import get_resource_principals_signer; signer = get_resource_principals_signer(); fs = ocifs.OCIFileSystem(signer=signer)`.
Always use binary modes (`'rb'`, `'wb'`) when opening files with `ocifs.OCIFileSystem.open()`. Handle text encoding and decoding explicitly in your application code.
Ensure your `oci` SDK version is compatible with `ocifs` (check `ocifs` release notes or PyPI dependencies for requirements). When troubleshooting, isolate whether the issue is with `ocifs` or the underlying `oci` SDK by attempting basic `oci` SDK operations.
Run `pip install ocifs` to install the library.
Remove the `encoding` argument and ensure you are opening the file in binary read (`'rb'`) or binary write (`'wb'`) mode. Handle text encoding/decoding explicitly after reading or before writing bytes.
Verify that `~/.oci/config` exists and is correctly configured with your OCI credentials. If using a custom path or profile, ensure it's passed explicitly: `fs = ocifs.OCIFileSystem(config='/path/to/my/config', profile='MY_PROFILE')`. Alternatively, ensure Resource Principal or Instance Principal is correctly configured if not using API keys.