Skip to content

Instantly share code, notes, and snippets.

@stephancom
Created June 10, 2009 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephancom/126968 to your computer and use it in GitHub Desktop.
Save stephancom/126968 to your computer and use it in GitHub Desktop.
# I realize this declaration looks kind of crazy, but I find it
# way more readable and DRY than a straight list would be
# optionally add octet-stream to this list - evaluate security risk of any before doing so
CONTENT_TYPES = %w(gif jpg jpe jpeg pjpeg bmp png pdf x-png tiff).map { |st| "image/#{st}"} +
%w(vnd.ms-excel vnd.ms-powerpoint msword pdf).map { |st| "application/#{st}"} +
[ "text/plain" ] +
# Don't blame me, blame Microsoft - this is for Office 2007.
# It makes a lot of MIME types that we shouldn't actually make,
# but that seems pretty harmless.
# original list from http://www.bram.us/2007/05/25/office-2007-mime-types-for-iis/
%w(ms-word ms-powerpoint ms-excel).map { |t|
%w(document template addin sheet sheet.binary slideshow presentation).map{ |s|
"application/vnd.#{t}.#{s}.macroEnabled.12"}} +
%w(wordprocessing presentation sheet).map { |t|
%w(document template sheet slideshow presentation).map{ |s|
"application/vnd.openxmlformats-officedocument.#{t}ml.#{s}"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment