mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
21 lines
734 B
Python
21 lines
734 B
Python
"""Reads document bytes from arbitrary S3 buckets (ADR-0060).
|
|
|
|
Uploaded files live across many source buckets (each `uploaded_files` row
|
|
carries its own `s3_file_bucket`), so — unlike the bucket-bound `S3Client` —
|
|
this reader takes the bucket per call. Used by the Bulk Document Download
|
|
orchestrator to stream each chosen file into the ZIP.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
|
|
class S3DocumentBytesReader:
|
|
def __init__(self, boto_s3_client: Any) -> None:
|
|
self._client = boto_s3_client
|
|
|
|
def read(self, bucket: str, key: str) -> bytes:
|
|
response: dict[str, Any] = self._client.get_object(Bucket=bucket, Key=key)
|
|
body: bytes = response["Body"].read()
|
|
return body
|