fix(file-manager): fix create-folder API to accept JSON request body

The create_folder endpoint was incorrectly defined to accept query
parameters instead of JSON request body, causing 400 errors when
called from the frontend.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
朱潮 2025-12-31 16:52:07 +08:00
parent 306cebd8f1
commit fbbf0c0653

View File

@ -260,15 +260,20 @@ async def delete_item(path: str):
@router.post("/create-folder") @router.post("/create-folder")
async def create_folder(path: str, name: str): async def create_folder(request: Dict[str, str]):
""" """
创建文件夹 创建文件夹
Args: Args:
path: 父目录路径 request: 包含path和name字段的JSON对象
name: 新文件夹名称
""" """
try: try:
path = request.get("path", "")
name = request.get("name", "")
if not name:
raise HTTPException(status_code=400, detail="文件夹名称不能为空")
parent_path = resolve_path(path) if path else resolve_path("projects") parent_path = resolve_path(path) if path else resolve_path("projects")
parent_path.mkdir(parents=True, exist_ok=True) parent_path.mkdir(parents=True, exist_ok=True)