feat(storage): support cloud storage

This commit is contained in:
MingxuanGame
2025-08-12 03:58:06 +00:00
parent 79b41010d5
commit cf3a6bbd21
11 changed files with 1075 additions and 1 deletions

34
app/storage/base.py Normal file
View File

@@ -0,0 +1,34 @@
from __future__ import annotations
import abc
class StorageService(abc.ABC):
@abc.abstractmethod
async def write_file(
self,
file_path: str,
content: bytes,
content_type: str = "application/octet-stream",
cache_control: str = "public, max-age=31536000",
) -> None:
raise NotImplementedError
@abc.abstractmethod
async def read_file(self, file_path: str) -> bytes:
raise NotImplementedError
@abc.abstractmethod
async def delete_file(self, file_path: str) -> None:
raise NotImplementedError
@abc.abstractmethod
async def is_exists(self, file_path: str) -> bool:
raise NotImplementedError
@abc.abstractmethod
async def get_file_url(self, file_path: str) -> str:
raise NotImplementedError
async def close(self) -> None:
pass