(path: str,
session_id: Optional[str] = Query(default=None))
| 786 | |
| 787 | @router.get('/files/stream') |
| 788 | async 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 | ) |
nothing calls this directly
no test coverage detected