This commit is contained in:
parent
33f266e552
commit
fe66612969
|
|
@ -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的文件")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue