Daniel Doubrovkine bio photo

Daniel Doubrovkine

aka dB., CTO at artsy.net, fun at playplay.io, NYC

Email Twitter LinkedIn Github

One of the issues that we ran to with implementing S3/CloudFront was that Internet Explorer refused to read CSS files from our CDN URL. The site would work beautifully in Chrome or Firefox and would ignore stylesheets in IE. Fortunately, IE9 has some good developer tools. This is what IE says in its console.

SEC7113: CSS was ignored due to mime type mismatch

Examining the HTTP response I quickly found out that the content-type came back blank. Turns out that our S3 sync code was not setting the content type and right_aws adds a blank content-type (lowercase) because Amazon S3 would otherwise reject it. Here’s a nice fix to my previous post.

content_type = MIME::Types.type_for(entry)[0]
logger.info("[#{Time.now}] uploading #{key} (#{content_type})")
s3i.put(to, key, File.open(entry), {
  'x-amz-acl' => 'public-read',
  'content-type' => content_type.to_s
})