The host file browser + viewer (/file/*, HostFilePage, the project Files card) and the context tree + editor (/_/*, Editor, the FilesPanel tree) are the file-explorer and context-editor plugins' now. - bridges (plugins/hubfiles.py): hostfiles.read (as the caller; operator- approved; machine tokens refused), context.read / context.write (owner) - /api/bundle, /api/file, /api/host-file, /api/host-files[/recent] retired; /api/host-file/raw stays for media and downloads - pages that route themselves: aiAgentPlugin.setRoute / onRoute; download, back; plugin pages pad above the phone composer - /file/* and /_/* redirect through opens (host-file, context-file) - mock: filesPlugins.ts; docs and CLAUDE.md updated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
"""``/api/host-file/raw`` — raw bytes of a host file (images/videos inline,
|
|
everything else a download).
|
|
|
|
The JSON browsing endpoints (``/api/host-file``, ``/api/host-files``,
|
|
``/api/host-files/recent``) left the core for the ``file-explorer`` live
|
|
plugin (``hostfiles.read`` bridge in ``plugins/hubfiles.py``). Raw byte
|
|
serving stays on the app origin so sandboxed frames can display images and
|
|
videos through ``aiAgentPlugin.mediaUrl`` and trigger authenticated downloads
|
|
through ``aiAgentPlugin.download`` with the caller's session cookies."""
|
|
|
|
from fastapi import APIRouter, HTTPException
|
|
|
|
from files.assets import _safe_file_response
|
|
from files.hostfiles import resolve
|
|
from users.caller import CallerDep
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/api/host-file/raw")
|
|
def host_file_raw(caller: CallerDep, path: str):
|
|
"""The file's bytes: images and videos inline, everything else a download."""
|
|
r = resolve(caller, path)
|
|
if r is None or not r.abs.is_file():
|
|
raise HTTPException(404, "file not found")
|
|
return _safe_file_response(r.abs)
|