feat: provision private S3 storage and attachment schema
This commit is contained in:
@@ -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",
|
||||
)
|
||||
Reference in New Issue
Block a user