diff --git a/src/databass/api/util.py b/src/databass/api/util.py index c481256..905e19e 100644 --- a/src/databass/api/util.py +++ b/src/databass/api/util.py @@ -5,6 +5,7 @@ from pathlib import Path from typing import Optional from dotenv import load_dotenv +from uuid import uuid4 load_dotenv() VERSION = getenv("VERSION") @@ -241,7 +242,7 @@ def get_image( def write_image( entity_id: int, entity_type: str, img_type: str, img_bytes: bytes ) -> str: - file_name = str(entity_id) + img_type + file_name = uuid4() + img_type file_path = IMG_BASE_PATH + "/" + entity_type + "/" + file_name with open(file_path, "wb") as img_file: img_file.write(img_bytes)