Refactors Services and Initial Test Implementation
This commit is contained in:
@@ -1,6 +1,26 @@
|
||||
from enum import Enum
|
||||
from io import BytesIO
|
||||
from typing import Callable
|
||||
|
||||
from storage_service.utils.file.validators import image_validator
|
||||
|
||||
|
||||
class FileType(Enum):
|
||||
PNG = "png"
|
||||
JPEG = "jpeg"
|
||||
|
||||
def get_content_type(self) -> str:
|
||||
match self:
|
||||
case FileType.PNG:
|
||||
return "image/png"
|
||||
case FileType.JPEG:
|
||||
return "image/jpeg"
|
||||
case _:
|
||||
raise ValueError("File Type Not Implemented")
|
||||
|
||||
def get_validator(self) -> Callable[[BytesIO], BytesIO]:
|
||||
match self:
|
||||
case FileType.PNG | FileType.JPEG:
|
||||
return image_validator
|
||||
case _:
|
||||
raise ValueError("File Type Not Implemented")
|
||||
|
||||
Reference in New Issue
Block a user