base_storage.py 783 B

123456789101112131415161718192021222324252627282930313233
  1. """Abstract interface for file storage implementations."""
  2. from abc import ABC, abstractmethod
  3. from collections.abc import Generator
  4. class BaseStorage(ABC):
  5. """Interface for file storage."""
  6. @abstractmethod
  7. def save(self, filename, data):
  8. raise NotImplementedError
  9. @abstractmethod
  10. def load_once(self, filename: str) -> bytes:
  11. raise NotImplementedError
  12. @abstractmethod
  13. def load_stream(self, filename: str) -> Generator:
  14. raise NotImplementedError
  15. @abstractmethod
  16. def download(self, filename, target_filepath):
  17. raise NotImplementedError
  18. @abstractmethod
  19. def exists(self, filename):
  20. raise NotImplementedError
  21. @abstractmethod
  22. def delete(self, filename):
  23. raise NotImplementedError