Pat Whitrock
Pat Whitrock

Reputation: 71

Displaying an image from AWS S3 with GitHub Flavored Markdown

I want to display images from my AWS S3 bucket in GitHub issues, but the aliased source URL provided by GitHub isn't working.

My markdown:

![test](https://s3-us-west-2.amazonaws.com/gitshoes/screenshot20140422-45272-isuk4x.png)

The HTML generated by GitHub:

<img src="https://camo.githubusercontent.com/b02d0cf44d4ba89549749d299ca9fcfb50612ee7/68747470733a2f2f73332d75732d776573742d322e616d617a6f6e6177732e636f6d2f67697473686f65732f73637265656e73686f7432303134303432322d34353237322d6973756b34782e706e67" alt="test" data-canonical-src="https://s3-us-west-2.amazonaws.com/gitshoes/screenshot20140422-45272-isuk4x.png" style="max-width:100%;">

The image url I provided (data-canonical-src) works, but the camo.githubusercontent.com just says "Not Found".

I tried using different image URLs, so the problem seems to be specific to AWS images. I have already made my bucket's AWS images public, so that is probably not the problem either.

Upvotes: 7

Views: 2431

Answers (1)

startswithaj
startswithaj

Reputation: 354

I think it might be because the content type response headers are not set to Content-Type: image/png

If you open up chrome inspector go to the network tab and then load your image url you will see it says in the response headers

 Content-Type:

https://i.sstatic.net/XVFBH.jpg if you look at that you'll see it has response headers content-type:image/jpeg

You'll probably need to configure your aws bucket to return content-type headers that reflect the content its returning.

Upvotes: 6

Related Questions