from fastapi import APIRouter, UploadFile, File
import shutil
import os

router = APIRouter(tags=["Upload"])


@router.post("/upload")
async def upload_image(file: UploadFile = File(...)):

    os.makedirs("data/raw", exist_ok=True)

    file_path = f"data/raw/{file.filename}"

    with open(file_path, "wb") as buffer:
        shutil.copyfileobj(file.file, buffer)

    return {
        "message": "File uploaded successfully",
        "path": file_path
    }