Amazon S3 not sending Content-Type header
I have an application that downloads content from various sources. It relies on the "Content-Type" header being set on images. The majority of web-servers do this correctly but it appears Amazon S3 server is not setting the Content-Type.
I assume Amazon servers are configured correctly so what could be the problem? Are these images not uploaded correctly? Or should I not be relying on content type being set?
Example
Thanks
Files uploaded to S3 need to have informed the Content-Type header. There isn't a default content-type definition like the ones you can do on a "normal" content web server (which wouldn't be that bad idea!) per folder.
You need to set this.
On the aws managerment console, if you browse to the file in question you can click on "properties". Then at the bottom of the screen on Metadata. If the Key Content-Type is set, change it to what you want, otherwise add a new Key, select Content-Type and set it to the appropriate value.
When uploading objects to S3 you have the option of setting a MIME type that will be returned in the Content-Type header to clients. S3 will not add this header on its own so if the user has not set that value no Content-Type header will be returned.
HTTP Servers are not required to provide the Content-Type header, so I would suggest a fallback mechanism. Perhaps you could look at the URL and guess from the file's extension? It's a bit of a hack, but it would work in the example you provided at least.