我见过application/csv和text/csv。

有区别吗?只要请求与可用的东西匹配,哪个有关系吗?它们可以互换吗?


RFC 7111

有一个RFC覆盖了它,并说使用text/csv。

本RFC更新了RFC 4180。


Excel

最近我发现了Excel application/vnd.ms-excel的显式mimetype。1996年在IANA注册。请注意所提出的关于受发送者摆布和您的机器被侵犯的担忧。

Media Type: application/vnd.ms-excel Name Microsoft Excel (tm) Required parameters: None Optional parameters: name Encoding considerations: base64 preferred Security considerations: As with most application types this data is intended for interpretation by a program that understands the data on the recipient's system. Recipients need to understand that they are at the "mercy" of the sender, when receiving this type of data, since data will be executed on their system, and the security of their machines can be violated. OID { org-id ms-files(4) ms-excel (3) } Object type spreadsheet Comments This Media Type/OID is used to identify Microsoft Excel generically (i.e., independent of version, subtype, or platform format).

我不知道供应商扩展是允许的。看看这个答案,以了解更多-感谢starbeamrainbowlabs的参考。


你应该根据RFC 4180使用"text/csv"。


使用Excel时的奇怪行为: 如果我导出到“基于文本,逗号分隔格式(csv)”,这是我在我的web服务器上上传后得到的mime类型:

[name] => data.csv
[type] => application/vnd.ms-excel

因此,微软似乎又在做自己的事情了,不考虑现有的标准:https://en.wikipedia.org/wiki/Comma-separated_values


我的用户允许上传CSV文件,目前还没有出现text/ CSV和application/ CSV。这些是通过finfo()确定的:

text/plain
text/x-csv

这些是通过浏览器传输的:

text/plain
application/vnd.ms-excel
text/x-csv

以下类型没有出现,但可以出现:

application/csv
application/x-csv
text/csv
text/comma-separated-values
text/x-comma-separated-values
text/tab-separated-values

对于任何与谷歌API mimeType *.csv文件斗争的人,我已经找到了谷歌API文档文件的MIME类型列表

Google Doc Format Conversion Format Corresponding MIME type
Documents HTML text/html
HTML (zipped) application/zip
Plain text text/plain
Rich text application/rtf
Open Office doc application/vnd.oasis.opendocument.text
PDF application/pdf
MS Word document application/vnd.openxmlformats-officedocument.wordprocessingml.document
EPUB application/epub+zip
Spreadsheets MS Excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Open Office sheet application/x-vnd.oasis.opendocument.spreadsheet
PDF application/pdf
CSV (first sheet only) text/csv
TSV (first sheet only) text/tab-separated-values
HTML (zipped) application/zip
Drawings JPEG image/jpeg
PNG image/png
SVG image/svg+xml
PDF application/pdf
Presentations MS PowerPoint application/vnd.openxmlformats-officedocument.presentationml.presentation
Open Office presentation application/vnd.oasis.opendocument.presentation
PDF application/pdf
Plain text text/plain
Apps Scripts JSON application/vnd.google-apps.script+json

来源: https://developers.google.com/drive/v3/web/manage-downloads#downloading_google_documents 下表: "谷歌文档格式和支持的导出MIME类型相互映射如下"

还有另外一个列表

MIME Type Description
application/vnd.google-apps.audio
application/vnd.google-apps.document Google Docs
application/vnd.google-apps.drawing Google Drawing
application/vnd.google-apps.file Google Drive file
application/vnd.google-apps.folder Google Drive folder
application/vnd.google-apps.form Google Forms
application/vnd.google-apps.fusiontable Google Fusion Tables
application/vnd.google-apps.map Google My Maps
application/vnd.google-apps.photo
application/vnd.google-apps.presentation Google Slides
application/vnd.google-apps.script Google Apps Scripts
application/vnd.google-apps.site Google Sites
application/vnd.google-apps.spreadsheet Google Sheets
application/vnd.google-apps.unknown
application/vnd.google-apps.video
application/vnd.google-apps.drive-sdk 3rd party shortcut

来源: https://developers.google.com/drive/v3/web/mime-types

但是第一个对我的用例更有帮助。