The OortWrapper
is a Python class that simplifies the process of interacting with Oort cloud storage. It provides an easy-to-use interface for working with Oort buckets and objects, enabling you to create buckets, upload, download, and delete objects, and list the contents of buckets.
To use the OortWrapper class, you first need to set up your Oort credentials as environment variables. You can do this by creating a .env file in the root directory of your project, and adding the following lines:
OORT_ACCESS_KEY=<your_access_key>
OORT_SECRET_KEY=<your_secret_key>
OORT_ENDPOINT_URL=<your_endpoint_url>
Replace <your_access_key>, <your_secret_key> , and <your_endpoint_url> with your actual Oort credentials.
Once you have your credentials set up, you can start using the OortWrapper class to interact with your Oort buckets. Here's an example of how to use the OortWrapper class to upload a file to an Oort bucket:
from oortwrapper import OortWrapper
oort = OortWrapper()
# Create a new bucket
oort.create_bucket("my-bucket")
# Upload a file to the bucket
with open("my-file.txt", "rb") as f:
oort.put_object("my-bucket", "my-file.txt", f.read())
The OortWrapper
class provides a simple Python interface for working with Oort buckets and objects.
List all available Oort buckets.
Returns:
List[str]
: A list of bucket names.
Create a new Oort bucket.
Arguments:
bucket_name
(str): The name of the new bucket.
Upload an object to an Oort bucket.
Arguments:
bucket_name
(str): The name of the bucket where the object will be uploaded.object_name
(str): The name of the object (e.g., the file name).data
(bytes): The binary data of the object.
Download an object from an Oort bucket.
Arguments:
bucket_name
(str): The name of the bucket where the object is stored.object_name
(str): The name of the object to download.
Returns:
bytes
: The binary data of the object.
List all objects in an Oort bucket.
Arguments:
bucket_name
(str): The name of the bucket to list objects for.
Returns:
List[str]
: A list of object names in the bucket.
Delete an object from an Oort bucket.
Arguments:
bucket_name
(str): The name of the bucket where the object is stored.object_name
(str): The name of the object to delete.