Spaces:
Runtime error
Runtime error
Greg
Claude Opus 4.7 (1M context)
feat(ta-01): backend-proxy photo URLs so they stop expiring
8ca1e92 Download backend/app/storage/base.py from Talosware/talos-access: direct link, hf CLI and curl.
- Browser
- Download file 981 Bytes
-
https://huggingface.co/spaces/Talosware/talos-access/resolve/main/backend/app/storage/base.py
- Command line
-
hf download hf://spaces/Talosware/talos-access/backend/app/storage/base.py
-
curl -L -o base.py https://huggingface.co/spaces/Talosware/talos-access/resolve/main/backend/app/storage/base.py
981 Bytes
| from typing import Protocol, Tuple | |
| class PhotoStorage(Protocol): | |
| def upload(self, account_id: int, user_id: int, content: bytes, ext: str) -> str: | |
| """Persiste el archivo y devuelve la ruta/identificador canónico que se guarda en BD.""" | |
| ... | |
| def delete(self, path_or_url: str) -> None: | |
| """Borra el archivo. Best-effort, no levanta si no existe.""" | |
| ... | |
| def get_url(self, path_or_url: str) -> str: | |
| """URL directa (pública/firmada) al objeto. Usada cuando el frontend | |
| puede consumir el storage directamente. La mayoría de los flujos | |
| ahora usan `fetch_bytes` vía el backend proxy en /api/v1/photos.""" | |
| ... | |
| def fetch_bytes(self, path_or_url: str) -> Tuple[bytes, str]: | |
| """Devuelve (contenido, content_type). Levanta FileNotFoundError | |
| si el objeto no existe. Usado por el endpoint serve_photo para | |
| proxear bytes desde cualquier backend con auth de nuestro JWT.""" | |
| ... | |