Content-Type Header 的标准命名约定
Standard Naming Conventions for Content-Type Header
我正在添加从 Web 服务器下载文件的功能。我正在用我自己的 Google Drive 帐户测试我的程序,但我不确定我应该如何处理 Content-Type Header 因为我对网络编程了解不多。
首先,我将两个文件上传到我的 google 驱动器帐户。
两者都是 完全相同的 zip 文件,但我将其中一个的扩展名从“zip”重命名为“ktx”,这在上传之前没有任何意义只是为了测试。
上传后,我检查了Content-Typeheaders个,原来的是“application/zip”,“application/x-zip" 为重命名的。
我很困惑,所以搜索了 Content-Type Header,但变得更加困惑。因为似乎有更多的 zip 名称,例如“multipart/x-zip”和“application/x-zip-compressed” .
所以我真的很想知道 Content-Type header.
是否有标准的命名约定
无论如何,我上传了我需要的所有文件类型,下面是我从 Google Drive.
获得的文件
Documents
text/plain (txt)
application/pdf
application/msword (doc)
application/vnd.ms-powerpoint (ppt)
application/vnd.ms-excel (xls)
application/rtf
application/vnd.openxmlformats-officedocument.wordprocessingml.document (docx)
application/vnd.openxmlformats-officedocument.presentationml.presentation (pptx)
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (xlsx)
Images
image/jpeg
image/png
image/gif
image/tiff (tif, tiff)
image/x-ms-bmp
image/x-photoshop (psd)
image/x-raw (raw)
application/illustrator (ai)
Compressed
application/zip
application/rar
application/x-tar (tar)
application/x-gzip (gz)
application/x-7z-compressed (7z)
application/x-zip (When zip, jar, xlsx or apk is renamed to meaningless
one.)
Audio files
audio/mpeg (mp3)
audio/x-wav
audio/x-ms-wma
audio/x-aiff (aiff)
audio/midi (mid)
application/ogg
Videos
video/mp4
video/x-msvideo (avi)
video/x-ms-asf
video/flv
video/quicktime (mov)
video/mpeg (mpg, vob)
video/x-ms-wmv
video/x-matroska (mkv)
Script or Source code files
text/html (htm, html)
text/x-csrc
text/x-c++src
text/x-csharp
text/x-java
text/x-python
text/css
application/x-javascript (js)
application/x-httpd-php
application/json
application/xml
Compiled or Executables
application/x-msdos-program (exe, dll, com, bat)
application/java-vm (class)
application/java-archive (jar)
application/x-python-code (pyc)
application/vnd.android.package-archive (apk)
Etc
application/x-shockwave-flash (swf)
有没有标准的命名约定?
只用上面的名字检查MIME类型可以吗?
Is there any standard naming convention?
Is it okay just to use the names above to check the MIME type?
有关标准类型,请参阅 Iana Media Types。
对于 MIME 类型,请参阅 Iana MIME Media Type Parameters。
[RFC2046] specifies that Media Types (formerly known as MIME types)
and Media Subtypes will be assigned and listed by the IANA.
The file types are determined once when uploading or the server always
checks when downloading?
通常,当请求文件时,服务器会检查文件扩展名并确定要使用的媒体类型。然而,某些服务器可能会检查文件的前几个字节 (magic number) 以确定文件类型是什么(例如,zip-files 以 PK.. 开头 - 点为 0x03 0x04)。
这可能是您看到 .zip
的 "application/zip"
和压缩的 .ktx
的 "application/x-zip"
的原因。附带说明:.xlsx
也是一个压缩文件。
根据实施情况,服务器可能会在收到文件时检查一次,并存储它以备后用,或者在每次下载时检查。
我正在添加从 Web 服务器下载文件的功能。我正在用我自己的 Google Drive 帐户测试我的程序,但我不确定我应该如何处理 Content-Type Header 因为我对网络编程了解不多。
首先,我将两个文件上传到我的 google 驱动器帐户。 两者都是 完全相同的 zip 文件,但我将其中一个的扩展名从“zip”重命名为“ktx”,这在上传之前没有任何意义只是为了测试。 上传后,我检查了Content-Typeheaders个,原来的是“application/zip”,“application/x-zip" 为重命名的。
我很困惑,所以搜索了 Content-Type Header,但变得更加困惑。因为似乎有更多的 zip 名称,例如“multipart/x-zip”和“application/x-zip-compressed” . 所以我真的很想知道 Content-Type header.
是否有标准的命名约定无论如何,我上传了我需要的所有文件类型,下面是我从 Google Drive.
获得的文件Documents
text/plain (txt)
application/pdf
application/msword (doc)
application/vnd.ms-powerpoint (ppt)
application/vnd.ms-excel (xls)
application/rtf
application/vnd.openxmlformats-officedocument.wordprocessingml.document (docx)
application/vnd.openxmlformats-officedocument.presentationml.presentation (pptx)
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (xlsx)
Images
image/jpeg
image/png
image/gif
image/tiff (tif, tiff)
image/x-ms-bmp
image/x-photoshop (psd)
image/x-raw (raw)
application/illustrator (ai)
Compressed
application/zip
application/rar
application/x-tar (tar)
application/x-gzip (gz)
application/x-7z-compressed (7z)
application/x-zip (When zip, jar, xlsx or apk is renamed to meaningless one.)
Audio files
audio/mpeg (mp3)
audio/x-wav
audio/x-ms-wma
audio/x-aiff (aiff)
audio/midi (mid)
application/ogg
Videos
video/mp4
video/x-msvideo (avi)
video/x-ms-asf
video/flv
video/quicktime (mov)
video/mpeg (mpg, vob)
video/x-ms-wmv
video/x-matroska (mkv)
Script or Source code files
text/html (htm, html)
text/x-csrc
text/x-c++src
text/x-csharp
text/x-java
text/x-python
text/css
application/x-javascript (js)
application/x-httpd-php
application/json
application/xml
Compiled or Executables
application/x-msdos-program (exe, dll, com, bat)
application/java-vm (class)
application/java-archive (jar)
application/x-python-code (pyc)
application/vnd.android.package-archive (apk)
Etc
application/x-shockwave-flash (swf)
有没有标准的命名约定?
只用上面的名字检查MIME类型可以吗?
Is there any standard naming convention?
Is it okay just to use the names above to check the MIME type?
有关标准类型,请参阅 Iana Media Types。
对于 MIME 类型,请参阅 Iana MIME Media Type Parameters。
[RFC2046] specifies that Media Types (formerly known as MIME types) and Media Subtypes will be assigned and listed by the IANA.
The file types are determined once when uploading or the server always checks when downloading?
通常,当请求文件时,服务器会检查文件扩展名并确定要使用的媒体类型。然而,某些服务器可能会检查文件的前几个字节 (magic number) 以确定文件类型是什么(例如,zip-files 以 PK.. 开头 - 点为 0x03 0x04)。
这可能是您看到 .zip
的 "application/zip"
和压缩的 .ktx
的 "application/x-zip"
的原因。附带说明:.xlsx
也是一个压缩文件。
根据实施情况,服务器可能会在收到文件时检查一次,并存储它以备后用,或者在每次下载时检查。