Compare commits
No commits in common. "6a9003ba7764b650eeb129cd5005ddb9bce0a5ff" and "251f5966fd59968ab74e6c20156f0094db9005b5" have entirely different histories.
6a9003ba77
...
251f5966fd
@ -191,10 +191,7 @@ async def upload_file(file: UploadFile = File(...), path: str = Form("")):
|
|||||||
# 创建目标目录(包括所有不存在的父目录)
|
# 创建目标目录(包括所有不存在的父目录)
|
||||||
target_path.mkdir(parents=True, exist_ok=True)
|
target_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
file_path = target_path / file.filename
|
||||||
# 将文件名中的空格替换为下划线
|
|
||||||
safe_filename = file.filename.replace(" ", "_") if file.filename else file.filename
|
|
||||||
file_path = target_path / safe_filename
|
|
||||||
|
|
||||||
# 如果文件已存在,检查是否覆盖
|
# 如果文件已存在,检查是否覆盖
|
||||||
if file_path.exists():
|
if file_path.exists():
|
||||||
@ -221,7 +218,6 @@ async def upload_file(file: UploadFile = File(...), path: str = Form("")):
|
|||||||
|
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise HTTPException(status_code=500, detail=f"文件上传失败: {str(e)}")
|
raise HTTPException(status_code=500, detail=f"文件上传失败: {str(e)}")
|
||||||
|
|
||||||
@ -965,4 +961,4 @@ async def batch_operation(operations: List[Dict[str, Any]]):
|
|||||||
}
|
}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise HTTPException(status_code=500, detail=f"批量操作失败: {str(e)}")
|
raise HTTPException(status_code=500, detail=f"批量操作失败: {str(e)}")
|
||||||
Loading…
Reference in New Issue
Block a user