MCPcopy Create free account
hub / github.com/modelscope/ms-agent / stream_file

Function stream_file

webui/backend/api.py:788–807  ·  view source on GitHub ↗
(path: str,
                      session_id: Optional[str] = Query(default=None))

Source from the content-addressed store, hash-verified

786
787@router.get('/files/stream')
788async def stream_file(path: str,
789 session_id: Optional[str] = Query(default=None)):
790 if session_id:
791 session_root = get_session_root(session_id)
792 root_abs = str(session_root.resolve())
793 full_path = resolve_file_path(root_abs, path)
794 else:
795 full_path = resolve_and_check_path(path)
796
797 media_type, _ = mimetypes.guess_type(full_path)
798 media_type = media_type or 'application/octet-stream'
799 return FileResponse(
800 full_path,
801 media_type=media_type,
802 filename=os.path.basename(full_path),
803 headers={
804 'Content-Disposition':
805 f'inline; filename="{os.path.basename(full_path)}"'
806 },
807 )

Callers

nothing calls this directly

Calls 4

get_session_rootFunction · 0.85
resolve_file_pathFunction · 0.85
resolve_and_check_pathFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected