change avatar (and other images) to relative path of s3 bucket

This commit is contained in:
2026-05-17 19:29:08 +08:00
parent 9748992135
commit 8940876694
3 changed files with 21 additions and 9 deletions
+12
View File
@@ -0,0 +1,12 @@
import os
OSS_BASE_URL = os.getenv("OSS_BASE_URL", "").rstrip("/")
def get_image_url(path: str) -> str:
if not path:
return ""
# 如果已经是完整 URL (比如 Google 原图),直接返回
if path.startswith(("http://", "https://")):
return path
# 否则拼接 OSS 基础域名
return f"{OSS_BASE_URL}/{path}"