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

@@ -22,10 +22,13 @@ export interface User {
displayName?: string | null
}
// File Upload
// File Upload (V2 API)
export interface UploadResponse {
batch_id: number
files: FileInfo[]
task_id: string
filename: string
file_size: number
file_type: string
status: 'pending' | 'processing' | 'completed' | 'failed'
}
export interface FileInfo {