Spaces:
Sleeping
Sleeping
Update api.py
Browse files
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 |
-
|
|
|
|
| 40 |
|
| 41 |
-
#
|
|
|
|
|
|
|
|
|
|
| 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 |
|