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:
@@ -5,14 +5,18 @@ Handles OCR task operations with user isolation
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import hashlib
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status, Query
|
||||
from fastapi import APIRouter, Depends, HTTPException, status, Query, UploadFile, File
|
||||
from fastapi.responses import FileResponse
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.deps import get_db, get_current_user
|
||||
from app.core.config import settings
|
||||
from app.models.user import User
|
||||
from app.models.task import TaskStatus
|
||||
from app.models.task import TaskStatus, TaskFile
|
||||
from app.schemas.task import (
|
||||
TaskCreate,
|
||||
TaskUpdate,
|
||||
@@ -21,6 +25,7 @@ from app.schemas.task import (
|
||||
TaskListResponse,
|
||||
TaskStatsResponse,
|
||||
TaskStatusEnum,
|
||||
UploadResponse,
|
||||
)
|
||||
from app.services.task_service import task_service
|
||||
from app.services.file_access_service import file_access_service
|
||||
|
||||
Reference in New Issue
Block a user