fix: add V2 file upload endpoint and update frontend to v2 API

Add missing file upload functionality to V2 API that was removed
during V1 to V2 migration. Update frontend to use v2 API endpoints.

Backend changes:
- Add /api/v2/upload endpoint in main.py for file uploads
- Import necessary dependencies (UploadFile, hashlib, TaskFile)
- Upload endpoint creates task, saves file, and returns task info
- Add UploadResponse schema to task.py schemas
- Update tasks router imports for consistency

Frontend changes:
- Update API_VERSION from 'v1' to 'v2' in api.ts
- Update UploadResponse type to match V2 API response format
  (task_id instead of batch_id, single file instead of array)

This fixes the 404 error when uploading files from the frontend.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
egg
2025-11-16 19:13:22 +08:00
parent 3f41a33877
commit ad5c8be0a3
5 changed files with 121 additions and 6 deletions

View File

@@ -101,3 +101,19 @@ class TaskHistoryQuery(BaseModel):
page_size: int = Field(default=50, ge=1, le=100)
order_by: str = Field(default="created_at")
order_desc: bool = Field(default=True)
class UploadFileInfo(BaseModel):
"""Uploaded file information"""
filename: str
file_size: int
file_type: str
class UploadResponse(BaseModel):
"""File upload response"""
task_id: str = Field(..., description="Created task ID")
filename: str = Field(..., description="Original filename")
file_size: int = Field(..., description="File size in bytes")
file_type: str = Field(..., description="File MIME type")
status: TaskStatusEnum = Field(..., description="Initial task status")