Search code examples
ruby-on-railsrubyrails-activestorage

What are the different 'content_type' for Active Storage?


Where can I find a list of all the different content_type category that Active Storage has? I am trying to change an icon based on the file type.

For example: In the documentation, there is application/pdf. I have also seen that there is image/png, video, audio or text. What interests me is the part before the file extension (therefore image or application). In which category would a Word or Powerpoint document be for example? How many content_type category there are?

Thank you in advance!


Solution

  • The content type is the MIME type of the uploaded document. Unless you excluded certain types it could be basically anything because a MIME type should have a certain structure but at least the suffix depends on the application.

    Some common media types are:

    • application/javascript
    • application/json
    • application/msword (.doc)
    • application/pdf
    • application/vnd.api+json
    • application/vnd.ms-excel (.xls)
    • application/vnd.ms-powerpoint (.ppt)
    • application/vnd.oasis.opendocument.text (.odt)
    • application/vnd.openxmlformats-officedocument.presentationml.presentation (.pptx)
    • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (.xlsx)
    • application/vnd.openxmlformats-officedocument.wordprocessingml.document(.docx)
    • application/x-www-form-urlencoded
    • application/xml
    • application/zip
    • audio/mpeg
    • image/gif
    • image/jpeg
    • image/png
    • multipart/form-data
    • text/csv
    • text/html
    • text/plain
    • text/xml