fix: 缩略图上传失败(upload_to_oss str/Path 类型不匹配) #602

Merged
auto-approve-bot merged 1 commits from fix/thumbnail-upload-str-path-bug into develop 2026-07-19 17:53:27 +08:00
+3 -2
View File
@@ -142,19 +142,20 @@ def _download_via_http(url: str, local_path: Path) -> bool:
return False
def upload_to_oss(local_path: Path, storage_key: str) -> str | None:
def upload_to_oss(local_path: Path | str, storage_key: str) -> str | None:
"""上传文件到 OSS,返回公开 URL。
大文件(>100MB)自动走分片上传,降低内存峰值,减少 OOM 风险。
上传加总超时保护(默认 300s),防止网络异常时无限挂死。
Args:
local_path: 本地文件路径
local_path: 本地文件路径Path 或 str 均可)
storage_key: 目标存储键
Returns:
公开访问 URL,上传失败或 OSS 未配置时返回 None。
"""
local_path = Path(local_path) # 统一转 Path,兼容 str 调用
bucket = oss_bucket()
if bucket is None:
return None