Store branding uploads in persistent storage
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from __future__ import annotations
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date, datetime, time, timezone
|
||||
from pathlib import Path
|
||||
@@ -769,7 +769,8 @@ def branch_edit_submit(
|
||||
# -----------------------------
|
||||
# Phase 7Q.2 - Firm Branding Settings
|
||||
# -----------------------------
|
||||
BRANDING_UPLOAD_ROOT = Path("app/ui/static/uploads/branding")
|
||||
BRANDING_UPLOAD_ROOT = Path("/app/data/storage/uploads/branding")
|
||||
BRANDING_PUBLIC_PREFIX = "/storage/uploads/branding"
|
||||
_ALLOWED_BRANDING_SUFFIXES = {".png", ".jpg", ".jpeg", ".webp", ".ico", ".svg"}
|
||||
_HEX_COLOR_RE = re.compile(r"^#[0-9a-fA-F]{6}$")
|
||||
|
||||
@@ -846,7 +847,7 @@ async def _save_branding_upload(upload: UploadFile | None, *, tenant_id: int, ki
|
||||
filename = f"{kind}_{uuid4().hex}{suffix}"
|
||||
path = folder / filename
|
||||
path.write_bytes(data)
|
||||
return "/static/uploads/branding/" + f"tenant_{tenant_id}/{filename}"
|
||||
return f"{BRANDING_PUBLIC_PREFIX}/tenant_{tenant_id}/{filename}"
|
||||
|
||||
|
||||
@router.get("/branding")
|
||||
@@ -1491,3 +1492,4 @@ def switch_active_branch(request: Request, branch_id: int):
|
||||
return _redirect_back(request)
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user