MCPcopy Create free account
hub / github.com/AstrBotDevs/AstrBot / get_open_api_file

Function get_open_api_file

astrbot/dashboard/api/open_api.py:266–277  ·  view source on GitHub ↗
(
    attachment_id: str = Query(...),
    _auth: AuthContext = Depends(require_file_scope),
    chat_service: ChatService = Depends(get_chat_service),
)

Source from the content-addressed store, hash-verified

264 openapi_extra={"x-astrbot-scope": "file"},
265)
266async 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")

Callers

nothing calls this directly

Calls 2

_open_api_errorFunction · 0.85

Tested by

no test coverage detected