feat(storage): add S3 image storage support with file-based config and migration script

This commit is contained in:
2026-07-18 08:03:18 +08:00
parent ddeec36a01
commit 3a931fe752
11 changed files with 242 additions and 30 deletions

View File

@@ -1,6 +1,6 @@
from datetime import datetime
from pydantic import BaseModel
from pydantic import BaseModel, model_validator
# ---------- Profile ----------
@@ -23,6 +23,13 @@ class ProfileOut(BaseModel):
model_config = {"from_attributes": True}
@model_validator(mode="after")
def _resolve_image_urls(self) -> "PostcardOut":
from app.storage import resolve_url
self.image_front = resolve_url(self.image_front) or None
self.image_back = resolve_url(self.image_back) or None
return self
# ---------- Postcard ----------
@@ -68,3 +75,10 @@ class PostcardOut(BaseModel):
updated_at: datetime
model_config = {"from_attributes": True}
@model_validator(mode="after")
def _resolve_image_urls(self) -> "PostcardOut":
from app.storage import resolve_url
self.image_front = resolve_url(self.image_front) or None
self.image_back = resolve_url(self.image_back) or None
return self