feat: implement S3 attachments and presigned uploads
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
from pydantic import AliasChoices, Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
@@ -15,6 +16,30 @@ class Settings(BaseSettings):
|
||||
idempotency_ttl_seconds: int = 86400
|
||||
instance_id: str = os.getenv("INSTANCE_ID") or os.getenv("HOSTNAME") or "api-local"
|
||||
shutdown_grace_seconds: int = 20
|
||||
s3_endpoint_url: str = Field(
|
||||
default="http://minio:9000",
|
||||
validation_alias=AliasChoices("S3_ENDPOINT_URL", "S3_ENDPOINT"),
|
||||
)
|
||||
s3_public_endpoint_url: str = Field(
|
||||
default="http://localhost:9000",
|
||||
validation_alias=AliasChoices("S3_PUBLIC_ENDPOINT_URL"),
|
||||
)
|
||||
presigned_upload_ttl_seconds: int = 300
|
||||
attachment_cleanup_interval_seconds: int = Field(default=60, ge=5, le=3600)
|
||||
attachment_cleanup_grace_seconds: int = Field(default=600, ge=0, le=86400)
|
||||
attachment_cleanup_batch_size: int = Field(default=100, ge=1, le=1000)
|
||||
s3_region: str = Field(default="us-east-1", validation_alias=AliasChoices("S3_REGION"))
|
||||
s3_bucket: str = Field(default="messenger-attachments", validation_alias=AliasChoices("S3_BUCKET"))
|
||||
s3_access_key: str = Field(
|
||||
default="messenger-api",
|
||||
validation_alias=AliasChoices("S3_ACCESS_KEY", "S3_ACCESS_KEY_ID"),
|
||||
)
|
||||
s3_secret_key: str = Field(
|
||||
default="change-me-api-secret",
|
||||
validation_alias=AliasChoices("S3_SECRET_KEY", "S3_SECRET_ACCESS_KEY"),
|
||||
)
|
||||
max_upload_bytes: int = 10 * 1024 * 1024
|
||||
max_image_pixels: int = 40_000_000
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env", env_file_encoding="utf-8", extra="ignore"
|
||||
|
||||
Reference in New Issue
Block a user