CJR61 Claude Sonnet 4.6 commited on
Commit
8199893
·
1 Parent(s): 48e076c

Fix missing uploads directory creation in container

Browse files

os.makedirs(save_dir, exist_ok=True) before writing uploaded file,
so the uploads/ dir is auto-created even when not present on disk.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app/utils.py +3 -0
app/utils.py CHANGED
@@ -13,6 +13,9 @@ def save_uploaded_file(save_dir, file):
13
  if ext.lower() not in ALLOWED_EXTENSIONS:
14
  raise ValueError(f"Unsupported file type '{ext}'. Allowed: {ALLOWED_EXTENSIONS}")
15
 
 
 
 
16
  # Generate unique ID (date prefix + uuid4) to avoid race condition
17
  image_id = datetime.now().strftime("%Y%m%d_%H%M%S") + "_" + uuid.uuid4().hex[:8]
18
  saved_path = os.path.join(save_dir, f"{image_id}.jpg")
 
13
  if ext.lower() not in ALLOWED_EXTENSIONS:
14
  raise ValueError(f"Unsupported file type '{ext}'. Allowed: {ALLOWED_EXTENSIONS}")
15
 
16
+ # Ensure upload directory exists
17
+ os.makedirs(save_dir, exist_ok=True)
18
+
19
  # Generate unique ID (date prefix + uuid4) to avoid race condition
20
  image_id = datetime.now().strftime("%Y%m%d_%H%M%S") + "_" + uuid.uuid4().hex[:8]
21
  saved_path = os.path.join(save_dir, f"{image_id}.jpg")