fix: improve image extension handling and error reporting in upload functions
Some checks failed
Build App / build (push) Failing after 6m56s
Some checks failed
Build App / build (push) Failing after 6m56s
This commit is contained in:
@@ -124,11 +124,16 @@ def main(args):
|
||||
if not image_b64:
|
||||
continue
|
||||
image_bytes = base64.b64decode(image_b64)
|
||||
file_name = f"tv-rotator-{ts}-{idx}.{ext}"
|
||||
MINIO_CLIENT.put_object(
|
||||
BUCKET, file_name, io.BytesIO(image_bytes), len(image_bytes),
|
||||
content_type=f"image/{ext}",
|
||||
)
|
||||
# Normalise ext: strip any URI junk, fall back to jpg
|
||||
safe_ext = ext if ext and len(ext) <= 5 and ext.isalnum() else "jpg"
|
||||
file_name = f"tv-rotator-{ts}-{idx}.{safe_ext}"
|
||||
try:
|
||||
MINIO_CLIENT.put_object(
|
||||
BUCKET, file_name, io.BytesIO(image_bytes), len(image_bytes),
|
||||
content_type=f"image/{safe_ext}",
|
||||
)
|
||||
except Exception as e:
|
||||
return {"status": "error", "message": f"MinIO upload failed: {e}"}
|
||||
public_url = f"https://content2.reversed.dev/{BUCKET}/{file_name}"
|
||||
urls.append(public_url)
|
||||
return {"status": "success", "urls": urls}
|
||||
|
||||
Reference in New Issue
Block a user