Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 835
Pat Whitrock Avatar asked Apr 22 '14 14:04

Pat Whitrock


People also ask

How do I show an image from my Amazon S3 on my website?

Easiest thing to do is make them public in s3, at least read-only. If you don't want them to be public on s3, for whatever reason, you could add a cloudfront distribution that will serve the images from your s3 bucket, and you can give cloudfront access to the files, without making the images public in s3.

How do I connect my AWS S3 to GitHub?

Select the Source provider: Github. Click the Connect to Github button. Authenticate Authorize AWS CodePipeline to access your Github Repos. After authentication, select the Repository with your static website files.

Is S3 good for hosting images?

Amazon S3 offers scalable storage that lets businesses store and manage endless amounts of items in the cloud. It not only offers huge storage allowance but it does so with extremely fast speeds, allowing users to quickly retrieve and share their stored images.


1 Answers

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.imgur.com/krwv2oe.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.

like image 124
startswithaj Avatar answered Oct 24 '22 18:10

startswithaj