19 lines
515 B
Python
19 lines
515 B
Python
|
|
"""ObjectStorage port — 对象存储能力契约。"""
|
||
|
|
|
||
|
|
from typing import Protocol, runtime_checkable
|
||
|
|
|
||
|
|
|
||
|
|
@runtime_checkable
|
||
|
|
class ObjectStorage(Protocol):
|
||
|
|
def upload(self, key: str, data: bytes, content_type: str) -> str:
|
||
|
|
"""Upload object, return its public or base URL."""
|
||
|
|
...
|
||
|
|
|
||
|
|
def get_url(self, key: str, expires: int = 3600) -> str:
|
||
|
|
"""Generate a presigned download URL."""
|
||
|
|
...
|
||
|
|
|
||
|
|
def delete(self, key: str) -> None:
|
||
|
|
"""Delete an object by key."""
|
||
|
|
...
|