Active Storage 有哪些不同 'content_type'?

What are the different 'content_type' for Active Storage?

我在哪里可以找到 Active Storage 具有的所有不同 content_type 类别的列表?我正在尝试根据文件类型更改图标。

例如: 在documentation中,有application/pdf。我还看到有 image/pngvideoaudiotext。我感兴趣的是文件扩展名之前的部分(因此 imageapplication)。例如,Word 或 Powerpoint 文档属于哪一类?有多少个 content_type 类别?

提前致谢!

内容类型是上传文件的MIME type。除非您排除了某些类型,否则它基本上可以是任何类型,因为 MIME 类型应该具有特定的结构,但至少后缀取决于应用程序。

一些common media types是:

  • 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

Rails 维护 Marcel 库来做任何内容类型的事情。 Rails 中可用的每种内容类型的规范列表位于此处:

https://github.com/rails/marcel/blob/main/lib/marcel/tables.rb