Base64 image uploaded to S3 opens when downloaded but looks broken in browser

  Kiến thức lập trình

I’m decoding a base64 string in Lambda and saving it to S3 bucket, using Boto3, like this:

obj.put(Body=base64.b64decode(image_base64), ContentType='image/jpeg', ACL='public-read')

The functions works but, if I open the uploaded image public URL or incorporate it into a tag, I get the classic “broken image” icon:

enter image description here

The crazy thing is that, if I download this same image (Using Ctrl+S or Save to…), I can view the image content correctly using computer image visualizer.

I want to be able to view the uploaded image in browser. The ContentType looks right, but maybe there’s something missing.