This commit is contained in:
hailin 2025-05-10 02:39:22 +08:00
parent 33f266e552
commit fe66612969
1 changed files with 5 additions and 0 deletions

View File

@ -26,6 +26,11 @@ def upload_user_file(user_id: str = Form(...), file: UploadFile = File(...)):
# 检查文件大小
file_size = len(file.file.read()) # 获取文件大小(字节)
file.file.seek(0) # 重置文件流指针回文件开头
# 打印接收到的文件大小
logger.info(f"接收到的文件大小: {file_size} 字节")
if file_size > MAX_FILE_SIZE:
raise HTTPException(status_code=400, detail="文件太大请上传不超过50MB的文件")