Island: Add IFileStorageService

This commit is contained in:
Mike Salvatore 2022-04-22 12:30:13 -04:00
parent 3c1e25b88c
commit 80a305ea81
2 changed files with 46 additions and 0 deletions

View File

@ -1,2 +1,3 @@
from .authentication.authentication_service import AuthenticationService from .authentication.authentication_service import AuthenticationService
from .authentication.json_file_user_datastore import JsonFileUserDatastore from .authentication.json_file_user_datastore import JsonFileUserDatastore
from .i_file_storage_service import IFileStorageService

View File

@ -0,0 +1,45 @@
import abc
from typing import BinaryIO
class IFileStorageService(metaclass=abc.ABCMeta):
"""
A service that allows the storage and retrieval of individual files.
"""
@abc.abstractmethod
def save_file(self, unsafe_file_name: str, file_contents: BinaryIO):
"""
Save a file, identified by a name
:param unsafe_file_name: An unsanitized file name that will identify the file
:param file_contents: The data to be stored in the file
"""
pass
@abc.abstractmethod
def open_file(self, unsafe_file_name: str) -> BinaryIO:
"""
Open a file and return a file-like object
:param unsafe_file_name: An unsanitized file name that identifies the file to be opened
:return: A file-like object providing access to the file's contents
:rtype: io.BinaryIO
"""
pass
@abc.abstractmethod
def delete_file(self, unsafe_file_name: str):
"""
Delete a file
:param unsafe_file_name: An unsanitized file name that identifies the file to be deleted
"""
pass
@abc.abstractmethod
def delete_all_files(self):
"""
Delete all files that have been stored using this service.
"""
pass