feat: 更新上传文件接口
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user