Browse Source

多货主init

zh 4 tháng trước cách đây
mục cha
commit
8a1309b928
2 tập tin đã thay đổi với 4 bổ sung3 xóa
  1. 0 2
      app/api/endpoints.py
  2. 4 1
      app/utils/path_utils.py

+ 0 - 2
app/api/endpoints.py

@@ -42,8 +42,6 @@ async def upload_file(
     
     path: 完整的文件路径 (例如: folder/subfolder/image.png)
     """
-    logger.info(f"接收到的文件名: {file.filename}")
-    logger.info(f"接收到的路径参数: {path}")
     # 验证和清理路径
     path = validate_path(path)
     

+ 4 - 1
app/utils/path_utils.py

@@ -2,6 +2,7 @@
 路径验证工具
 """
 import re
+import os
 from fastapi import HTTPException
 
 
@@ -55,7 +56,9 @@ def sanitize_filename(filename: str) -> str:
     """
     if not filename:
         raise HTTPException(status_code=400, detail="文件名不能为空")
-    
+
+    filename = os.path.basename(filename)
+
     # 移除路径分隔符
     filename = filename.replace('/', '').replace('\\', '')