from fastapi import APIRouter, UploadFile, File router = APIRouter() @router.post("/user/upload") async def upload_file(file: UploadFile = File(...)): file_location = f"/path/to/your/uploads/{file.filename}" with open(file_location, "wb") as buffer: contents = await file.read() buffer.write(contents) return {"filename": file.filename, "location": file_location}