Model/infrastructure/s3/s3_document_bytes_reader.py
Khalim Conn-Kowlessar 79fa46d97c Read document bytes from an arbitrary source bucket 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-08 09:42:37 +00:00

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