(
attachment_id: str = Query(...),
_auth: AuthContext = Depends(require_file_scope),
chat_service: ChatService = Depends(get_chat_service),
)
| 264 | openapi_extra={"x-astrbot-scope": "file"}, |
| 265 | ) |
| 266 | async def get_open_api_file( |
| 267 | attachment_id: str = Query(...), |
| 268 | _auth: AuthContext = Depends(require_file_scope), |
| 269 | chat_service: ChatService = Depends(get_chat_service), |
| 270 | ): |
| 271 | try: |
| 272 | file_path, mimetype = await chat_service.resolve_attachment_file(attachment_id) |
| 273 | return FileResponse(file_path, media_type=mimetype) |
| 274 | except ChatServiceError as exc: |
| 275 | return _open_api_error(str(exc)) |
| 276 | except (FileNotFoundError, OSError): |
| 277 | return _open_api_error("File access error") |
| 278 | |
| 279 | |
| 280 | @router.websocket("/chat/ws") |
nothing calls this directly
no test coverage detected