21 lines
617 B
Python
21 lines
617 B
Python
from typing import Protocol
|
|
|
|
_client: "StorageClient | None" = None
|
|
|
|
|
|
class StorageClient(Protocol):
|
|
def upload(self, path: str, data: bytes) -> bool: ...
|
|
def get_url(self, path: str) -> str: ...
|
|
def get_public_url(self, path: str) -> str: ...
|
|
def delete(self, path: str) -> bool: ...
|
|
def download(self, path: str) -> tuple[bytes, str]: ...
|
|
|
|
|
|
def get_storage_client() -> "StorageClient":
|
|
assert _client is not None, "Storage client not initialised — call init_storage() at startup"
|
|
return _client
|
|
|
|
|
|
def _set_storage_client(c: "StorageClient") -> None:
|
|
global _client
|
|
_client = c
|