常用的 MIME type

ゞ 浴缸里的玫瑰 2023-02-14 02:59 138阅读 0赞
  • MIME
    MIME(Multipurpose Internet Mail Extensions)多用途互联网邮件扩展类型。是设定某种扩展名的文件用一种应用程序来打开的方式类型,当该扩展名文件被访问的时候,浏览器会自动使用指定应用程序来打开。多用于指定一些客户端自定义的文件名,以及一些媒体文件打开方式。
    HTTP协议也使用了这个标准。当响应数据被发回到客户端浏览器的时候,响应头Content-Type应该告诉客户端:我发给你的数据是什么类型(以便客户浏览器对拿到的数据做解析)。
  • 常用的MIME类型
    将mime_type和对应的响应头Content-Type的值的映射关系存储在一个JS对象中,调用即可:
    以下数据提取来源:https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

    var mimeTypes = {

    1. ".aac": "audio/aac", // AAC audio
    2. ".abw": "application/x-abiword", // AbiWord document
    3. ".arc": "application/x-freearc", // Archive document (multiple files embedded)
    4. ".avi": "video/x-msvideo", // AVI: Audio Video Interleave
    5. ".azw": "application/vnd.amazon.ebook", // Amazon Kindle eBook format
    6. ".bin": "application/octet-stream", // Any kind of binary data
    7. ".bmp": "image/bmp", // Windows OS/2 Bitmap Graphics
    8. ".bz": "application/x-bzip", // BZip archive
    9. ".bz2": "application/x-bzip2", // BZip2 archive
    10. ".csh": "application/x-csh", // C-Shell script
    11. ".css": "text/css", // Cascading Style Sheets (CSS)
    12. ".csv": "text/csv", // Comma-separated values (CSV)
    13. ".doc": "application/msword", // Microsoft Word
    14. ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", // Microsoft Word (OpenXML)
    15. ".eot": "application/vnd.ms-fontobject", // MS Embedded OpenType fonts
    16. ".epub": "application/epub+zip", // Electronic publication (EPUB)
    17. ".gif": "image/gif", // Graphics Interchange Format (GIF)
    18. ".htm": "text/html",
    19. ".html": "text/html", // HyperText Markup Language (HTML)
    20. ".ico": "image/vnd.microsoft.icon", // Icon format
    21. ".ics": "text/calendar", // iCalendar format
    22. ".jar": "application/java-archive", // Java Archive (JAR)
    23. ".jpeg": "image/jpeg",
    24. ".jpg": "image/jpeg", // JPEG images
    25. ".js": "text/javascript", // JavaScript
    26. ".json": "application/json", // JSON format
    27. ".jsonld": "application/ld+json", // JSON-LD format
    28. ".mid": "audio/midi audio/x-midi",
    29. ".midi": "audio/midi audio/x-midi", // Musical Instrument Digital Interface (MIDI)
    30. ".mjs": "text/javascript", // JavaScript module
    31. ".mp3": "audio/mpeg", // MP3 audio
    32. ".mpeg": "video/mpeg", // MPEG Video
    33. ".mpkg": "application/vnd.apple.installer+xml", // Apple Installer Package
    34. ".odp": "application/vnd.oasis.opendocument.presentation", // OpenDocument presentation document
    35. ".ods": "application/vnd.oasis.opendocument.spreadsheet", // OpenDocument spreadsheet document
    36. ".odt": "application/vnd.oasis.opendocument.text", // OpenDocument text document
    37. ".oga": "audio/ogg", // OGG audio
    38. ".ogv": "video/ogg", // OGG video
    39. ".ogx": "application/ogg", // OGG
    40. ".otf": "font/otf", // OpenType font
    41. ".png": "image/png", // Portable Network Graphics
    42. ".pdf": "application/pdf", // Adobe Portable Document Format (PDF)
    43. ".ppt": "application/vnd.ms-powerpoint", // Microsoft PowerPoint
    44. ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation", // Microsoft PowerPoint (OpenXML)
    45. ".rar": "application/x-rar-compressed", // RAR archive
    46. ".rtf": "application/rtf", // Rich Text Format (RTF)
    47. ".sh": "application/x-sh", // Bourne shell script
    48. ".svg": "image/svg+xml", // Scalable Vector Graphics (SVG)
    49. ".swf": "application/x-shockwave-flash", // Small web format (SWF) or Adobe Flash document
    50. ".tar": "application/x-tar", // Tape Archive (TAR)
    51. ".tif": "image/tiff",
    52. ".tiff": "image/tiff", // Tagged Image File Format (TIFF)
    53. ".ttf": "font/ttf", // TrueType Font
    54. ".txt": "text/plain", // Text, (generally ASCII or ISO 8859-n)
    55. ".vsd": "application/vnd.visio", // Microsoft Visio
    56. ".wav": "audio/wav", // Waveform Audio Format
    57. ".weba": "audio/webm", // WEBM audio
    58. ".webm": "video/webm", // WEBM video
    59. ".webp": "image/webp", // WEBP image
    60. ".woff": "font/woff", // Web Open Font Format (WOFF)
    61. ".woff2": "font/woff2", // Web Open Font Format (WOFF)
    62. ".xhtml": "application/xhtml+xml", // XHTML
    63. ".xls": "application/vnd.ms-excel", // Microsoft Excel
    64. ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // Microsoft Excel (OpenXML)
    65. ".xml": "application/xml", // 代码对普通用户来说不可读 (RFC 3023, section 3)
    66. ".xml": "text/xml", // XML 代码对普通用户来说可读 (RFC 3023, section 3)
    67. ".xul": "application/vnd.mozilla.xul+xml", // XUL
    68. ".zip": "application/zip", // ZIP archive
    69. ".3gp": "video/3gpp", // 含视频
    70. // ".3gp": "audio/3gpp", // 3GPP audio/video container(若不含视频)
    71. ".3g2": "video/3gpp2", // 含视频
    72. // ".3g2": "audio/3gpp2", // 3GPP2 audio/video container(若不含视频)
    73. ".7z": "application/x-7z-compressed", // 7-zip archive

    };

发表评论

表情:
评论列表 (有 0 条评论,138人围观)

还没有评论,来说两句吧...

相关阅读

    相关 什么是 MIME Type

    一、 首先,我们要了解浏览器是如何处理内容的。在浏览器中显示的内容有 HTML、有 XML、有 GIF、还有 Flash ……那么,浏览器是如何区分它们,决定什么内容用什么形