Skip to content

Instantly share code, notes, and snippets.

@acuppy
Created July 21, 2013 04:53
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save acuppy/6047526 to your computer and use it in GitHub Desktop.
Save acuppy/6047526 to your computer and use it in GitHub Desktop.
All major document mime types (Microsoft Office, Apple iWork, Adobe PDF) as a Ruby Module
module DocumentFileTypes
module Microsoft
WORD = %w(
application/msword
application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/vnd.openxmlformats-officedocument.wordprocessingml.template
application/vnd.ms-word.document.macroEnabled.12
application/vnd.ms-word.template.macroEnabled.12
)
EXCEL = %w(
application/vnd.ms-excel
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.openxmlformats-officedocument.spreadsheetml.template
application/vnd.ms-excel.sheet.macroEnabled.12
application/vnd.ms-excel.template.macroEnabled.12
application/vnd.ms-excel.addin.macroEnabled.12
application/vnd.ms-excel.sheet.binary.macroEnabled.12
)
POWER_POINT = %w(
application/vnd.ms-powerpoint
application/vnd.openxmlformats-officedocument.presentationml.presentation
application/vnd.openxmlformats-officedocument.presentationml.template
application/vnd.openxmlformats-officedocument.presentationml.slideshow
application/vnd.ms-powerpoint.addin.macroEnabled.12
application/vnd.ms-powerpoint.presentation.macroEnabled.12
application/vnd.ms-powerpoint.template.macroEnabled.12
application/vnd.ms-powerpoint.slideshow.macroEnabled.12
)
end
module Apple
IWORK = ['application/x-iwork-pages-sffpages']
end
module Adobe
PDF = ["application/pdf"]
end
TEXT_DOC_MIME_TYPES = Microsoft::WORD + ['text/plain']
SPREADSHEET_MIME_TYPES = Microsoft::EXCEL + ['text/csv']
PRESENTATION_MIME_TYPES = Microsoft::POWER_POINT
ALL = TEXT_DOC_MIME_TYPES + SPREADSHEET_MIME_TYPES + PRESENTATION_MIME_TYPES + Apple::IWORK + Adobe::PDF
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment