feat: 更新上传文件接口

This commit is contained in:
2026-09-06 19:18:16 +08:00
parent 30b5bf2aa1
commit a81ff36f21
2 changed files with 7 additions and 6 deletions

View File

@@ -1,3 +1,5 @@
import uuid
from fastapi import UploadFile, File, HTTPException
from config.rustfs import s3
@@ -23,7 +25,7 @@ BUCKET = 'family'
NGINX_PROXY = 'rustfs'
async def upload_file(md5: str, file: UploadFile = File(...)) -> str:
async def upload_file(file: UploadFile = File(...)) -> str:
# 校验文件类型
if file.content_type not in ALLOWED_IMAGE_TYPES:
raise HTTPException(
@@ -32,7 +34,7 @@ async def upload_file(md5: str, file: UploadFile = File(...)) -> str:
)
file_ext = file.filename.split('.')[-1]
unique_filename = f"{md5}.{file_ext}"
unique_filename = f"{uuid.uuid4().hex}.{file_ext}"
file_content = await file.read()