Search code examples
amazon-s3jpegamazon-cloudfront

S3/Cloudfront does not send image/jpeg Content-Type


I have a .jpg file stored in S3 and distributed using CloudFront. I can view the file when I download it, but I cannot view the file in Chrome or Safari. From what I can tell, I can't view the file in a browser because the Content-Type isn't getting sent despite the fact that I've set it in S3.

The file's overview in the S3 console

The file's properties in the S3 console, which show that Content-Type is set to image/jpeg.

What I see when I click "Open" in the S3 console's "Overview" page

What I see when I enter a signed CloudFront url into the browser

You can see what happens when you enter this signed CloudFront url into a browser. It should remain valid for roughly 24 hours after this post. https://media.development.doctheapp.com/claims/us-east-1:4877c3da-786a-4b3b-b1e0-c70bde0f9c4e741afc7c5a8304564963080a98e5675d09d1aca3d623911e34bd3b4eb0808579/300ae913-8f88-44b9-a4ab-e46d11133c76/receipt.jpg?Expires=1526533530&Signature=crnjhje1noP-7WfBMI6rMDPd-zdCAVKLaojFFNvxCZEdx0~EJHeqbL8oKwL64AULavekMHm~2r6vHto1d4IAt5eoLpbZR~q5PAfhSakte1iNNvuTxQ7q-mYOwoCemb5VD~bFXUBdrF1yiybaRHw-v6USbw53QZ2Qa4hfDkqgoEKwvEznBvR~sQnk5v-slX8~aJBhySS5XpkfdoE-yl8hh697xIyH~OliwrCg7h5iSkotwW9~EvTnLoVkXkuvru35eLhN4~gGMs3WDUAuucOl8JZdeg6CjAQQ~JWv6FJnb2wyvGrGJzOf70~8s08~qSqiCroyZfqUiZmw20eCIWXp4A__&Key-Pair-Id=APKAJVSE2BEPIQCCPH6Q


Solution

  • It seems like the original image is a TIFF file, not a JPEG. That's why you cannot see it in a browser but can open it upon download. The content type header is being sent correctly by Cloudfront if you look at the response headers.