import os import shutil from fastapi import APIRouter, UploadFile, File, HTTPException from app.core.config import settings router = APIRouter(tags=["Storage"]) @router.post("/storage/upload") async def upload_file(file: UploadFile = File(...)): """Upload a file to landing storage staging area.""" try: os.makedirs(settings.UPLOADS_DIR, exist_ok=True) dest_path = os.path.join(settings.UPLOADS_DIR, file.filename) with open(dest_path, "wb") as buffer: shutil.copyfileobj(file.file, buffer) s3_uri = f"s3://dlh-landing/uploads/{file.filename}" return { "status": "success", "filename": file.filename, "local_path": dest_path, "s3_uri": s3_uri, "message": f"File '{file.filename}' successfully uploaded to landing storage." } except Exception as e: raise HTTPException(status_code=500, detail=f"File upload error: {str(e)}")