Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
I believe you are able to set content-type when uploading the file to Amazon S3. I don't know what it does about default content-type headers though. And this obviously doesn't help you when it's not your files. –  kaerast Jun 1 '10 at 12:03
    
I did see that, but not having an account I can't try it out. Knowing the answer wouldn't fix my problem but it might suggest that I work around not relying on content-type. –  Luke____ Jun 1 '10 at 12:28

3 Answers 3

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.