From 3e240550c719bb428e7b1671e518b7a909940234 Mon Sep 17 00:00:00 2001 From: hnolan Date: Fri, 11 Jul 2025 22:59:17 -0400 Subject: [PATCH] Use uuids for image filenames --- src/databass/api/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)