ABDALLALSWAITI commited on
Commit
5ec1f6e
·
verified ·
1 Parent(s): 0d059f2

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +7 -2
api.py CHANGED
@@ -36,10 +36,15 @@ def save_uploaded_images(images: List[UploadFile], temp_dir: str):
36
  # Save image to temp directory
37
  image_path = os.path.join(images_dir, image.filename)
38
  with open(image_path, 'wb') as f:
39
- f.write(image.file.read())
 
40
 
41
- # Create mapping for HTML replacement
 
 
 
42
  image_mapping[image.filename] = f"images/{image.filename}"
 
43
 
44
  return image_mapping
45
 
 
36
  # Save image to temp directory
37
  image_path = os.path.join(images_dir, image.filename)
38
  with open(image_path, 'wb') as f:
39
+ content = image.file.read()
40
+ f.write(content)
41
 
42
+ # Reset file pointer for potential reuse
43
+ image.file.seek(0)
44
+
45
+ # Create mapping with relative path
46
  image_mapping[image.filename] = f"images/{image.filename}"
47
+ print(f"Saved image: {image.filename} -> {image_path}")
48
 
49
  return image_mapping
50