feat: provision private S3 storage and attachment schema

This commit is contained in:
Самохвалов Андрей Ремович
2026-10-02 13:01:50 +03:00
parent bd41f2d93d
commit 22f7bcddf5
14 changed files with 309 additions and 25 deletions
+25
View File
@@ -0,0 +1,25 @@
"""Private S3 access shared by attachment routes and maintenance jobs."""
import os
from functools import lru_cache
from pathlib import Path
from minio import Minio
BUCKET = "messenger-attachments"
def secret(name: str) -> str:
return Path(os.environ[f"{name}_FILE"]).read_text(encoding="utf-8").strip()
@lru_cache(maxsize=1)
def storage() -> Minio:
return Minio(
os.environ.get("S3_ENDPOINT", "s3:9000"),
access_key=secret("S3_ACCESS_KEY_ID"),
secret_key=secret("S3_SECRET_ACCESS_KEY"),
secure=False,
region="us-east-1",
)