(session_id: str, file: UploadFile = File(...))
| 8 | |
| 9 | @router.post("/api/uploads/{session_id}") |
| 10 | async def upload_attachment(session_id: str, file: UploadFile = File(...)): |
| 11 | try: |
| 12 | manager = ensure_known_session(session_id, require_connection=False) |
| 13 | except ValidationError as exc: |
| 14 | raise HTTPException(status_code=400, detail=str(exc)) |
| 15 | try: |
| 16 | record = await manager.attachment_service.save_upload_file(session_id, file) |
| 17 | except ValidationError: |
| 18 | raise HTTPException(status_code=400, detail="Session not connected") |
| 19 | except Exception as exc: |
| 20 | logger = get_server_logger() |
| 21 | logger.error( |
| 22 | "Failed to save attachment", |
| 23 | log_type=LogType.REQUEST, |
| 24 | session_id=session_id, |
| 25 | error=str(exc), |
| 26 | ) |
| 27 | raise HTTPException(status_code=500, detail="Failed to store attachment") |
| 28 | |
| 29 | ref = record.ref |
| 30 | return { |
| 31 | "attachment_id": ref.attachment_id, |
| 32 | "name": ref.name, |
| 33 | "mime_type": ref.mime_type, |
| 34 | "size": ref.size, |
| 35 | } |
| 36 | |
| 37 | |
| 38 | @router.get("/api/uploads/{session_id}") |
nothing calls this directly
no test coverage detected