Spaces:
Running on T4
Running on T4
Download backend/app/common/media.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 825 Bytes
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/common/media.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine/backend/app/common/media.py
-
curl -L -o media.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/common/media.py
825 Bytes
| """Short-lived read URLs for stored media. Every module that returns a MediaRef builds it here.""" | |
| from datetime import UTC, datetime, timedelta | |
| from uuid import UUID | |
| from app.common.schemas import MediaRef | |
| from app.integrations.storage import StorageClient | |
| from app.modules.uploads.models import Upload | |
| def media_ref(storage: StorageClient, upload_id: UUID, object_key: str, seconds: float | None = None) -> MediaRef: | |
| return MediaRef(upload_id=upload_id, url=storage.presign_get(object_key), | |
| expires_at=datetime.now(UTC) + timedelta(seconds=storage.download_ttl), seconds=seconds) | |
| def upload_ref(storage: StorageClient, upload: Upload | None, seconds: float | None = None) -> MediaRef | None: | |
| return media_ref(storage, upload.id, upload.object_key, seconds) if upload is not None else None | |