feat: add crop and optimized variants, implement idempotent worker

This commit is contained in:
2026-11-11 21:41:03 +03:00
parent a99d558f32
commit 4df4307367
2 changed files with 65 additions and 15 deletions
+9 -1
View File
@@ -287,12 +287,20 @@ async def download_attachment(attachment_id: UUID, variant: str = Query("origina
raise HTTPException(409, "Attachment not ready")
key = att.s3_key
mime = att.content_type
if variant == "thumbnail":
key = f"{att.s3_key}_thumb.jpg"
mime = "image/jpeg"
elif variant == "crop":
key = f"{att.s3_key}_crop.jpg"
mime = "image/jpeg"
elif variant == "optimized":
key = f"{att.s3_key}_opt.webp"
mime = "image/webp"
obj = s3.get_object(Bucket=BUCKET, Key=key)
content = obj["Body"].read()
mime = "image/jpeg" if variant == "thumbnail" else att.content_type
return Response(content=content, media_type=mime)
if __name__ == "__main__":