Hopeit Engine S3 Storage Toolkit
Project description
hopeit.aws.s3 plugin
This library is part of hopeit.engine:
This library provides a ObjectStorage
class to store and retrieve @dataobjects
and files from S3 and compatible services as a plugin for the popular hopeit.engine
reactive microservices framework.
It supports the prefix
setting, which is a prefix to be used for every element (object or file) stored in the S3 bucket. This prefix can be used to organize and categorize stored data within the bucket. Additionally, it supports the partition_dateformat
setting, which is a date format string used to prefix file names for partitioning saved files into different subfolders based on the event timestamp (event_ts()). For example, using %Y/%m/%d
will store each data object in a folder structure like year/month/day/, providing a way to efficiently organize and retrieve data based on date ranges. These settings can be used together to achieve more granular organization of data within the bucket.
Installation
Python library that provides helpers to store and retrieve @dataobjects
and files to S3-compatible services
pip install hopeit.aws.s3
Usage
from hopeit.dataobjects import dataobject, dataclass
from hopeit.aws.s3 import ObjectStorage, ObjectStorageSettings, ConnectionConfig
# Create a connection configuration
conn_config = ConnectionConfig(
aws_access_key_id="your-access-key-id",
aws_secret_access_key="your-secret-access-key",
region_name="your-region-name"
)
# Create settings for ObjectStorage
settings = ObjectStorageSettings(
bucket="your-bucket-name",
connection_config=conn_config
)
# Create an ObjectStorage instance
storage = ObjectStorage.with_settings(settings)
# Connect to the ObjectStorage
await storage.connect()
# hopeit.engine data object
@dataobject
@dataclass
class Something:
key: str
value: str
something = Something(key="my_key", value="some_value")
# Store a data object
await storage.store(key=something.key, value=something)
# Retrieve a data object
retrieved_object = await storage.get(key=something.key, datatype=Something)
print(retrieved_object)
Example Usage
In the apps/examples/aws-example/
directory, you can find a full example hopeit.engine
app that demonstrates the usage of the hopeit.aws.s3
plugin within the hopeit.engine
framework. This example showcases how to store and retrieve @dataobjects
and files from S3 using the ObjectStorage
class.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hopeit_aws_s3-0.2.0.tar.gz
.
File metadata
- Download URL: hopeit_aws_s3-0.2.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6605e326f6d774a0845fae14716ea7d62a8acd1691360528307629c65435e00c |
|
MD5 | 8c8c961cf41840a4d596bdfd372c5387 |
|
BLAKE2b-256 | 4cd4ee2e3db459974c29447f953199b091274c788187565df71f53fbba240de4 |
File details
Details for the file hopeit.aws.s3-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: hopeit.aws.s3-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5241eb884f6103ad1b4d122c55fe8050465976d0984c5b8a044d25fbd53ffdb |
|
MD5 | f7bd77287d5a3cfbf9a48721731b6593 |
|
BLAKE2b-256 | eedb87cc9bfb29bad455b0ead675b69ce06ea69590f357f2979c63447054583d |