mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
22 lines
644 B
Python
22 lines
644 B
Python
from typing import Any
|
|
|
|
|
|
class S3Client:
|
|
def __init__(self, boto_s3_client: Any, bucket: str) -> None:
|
|
self._client = boto_s3_client
|
|
self._bucket = bucket
|
|
|
|
@property
|
|
def bucket(self) -> str:
|
|
return self._bucket
|
|
|
|
def get_object(self, key: str) -> bytes:
|
|
response: dict[str, Any] = self._client.get_object(
|
|
Bucket=self._bucket, Key=key
|
|
)
|
|
body: bytes = response["Body"].read()
|
|
return body
|
|
|
|
def put_object(self, key: str, body: bytes) -> str:
|
|
self._client.put_object(Bucket=self._bucket, Key=key, Body=body)
|
|
return f"s3://{self._bucket}/{key}"
|