Initial Functional Implementation of S3 MicroService
This commit is contained in:
0
resize_image_service/utils/__init__.py
Normal file
0
resize_image_service/utils/__init__.py
Normal file
0
resize_image_service/utils/enums/__init__.py
Normal file
0
resize_image_service/utils/enums/__init__.py
Normal file
9
resize_image_service/utils/enums/file_type.py
Normal file
9
resize_image_service/utils/enums/file_type.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class FileType(Enum):
|
||||
PNG = "png"
|
||||
JPEG = "jpeg"
|
||||
|
||||
|
||||
CONTENT_TYPE = {FileType.PNG: "image/png", FileType.JPEG: "image/jpeg"}
|
||||
9
resize_image_service/utils/file_name_hash.py
Normal file
9
resize_image_service/utils/file_name_hash.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import base64
|
||||
from hashlib import md5
|
||||
|
||||
|
||||
def file_name_hash(username: str, file_postfix: str) -> str:
|
||||
hashed_username = md5(username.encode("utf-8")).digest()
|
||||
hashed_username = base64.b64encode(hashed_username).decode()
|
||||
|
||||
return f"{hashed_username}_{file_postfix}"
|
||||
Reference in New Issue
Block a user