转自:https://blog.csdn.net/m0_73746790/article/details/128618371
Content-Type常用对照
1 import java.util.Objects; 2 /** 3 * Content-Type常用对照 4 */ 5 public enum MimeTypeEnum { 6 AAC("acc","AAC音频","audio/aac"), 7 ABW("abw","AbiWord文件","application/x-abiword"), 8 ARC("arc","存档文件","application/x-freearc"), 9 AVI("avi","音频视频交错格式","video/x-msvideo"), 10 AZW("azw","亚马逊Kindle电子书格式","application/vnd.amazon.ebook"), 11 BIN("bin","任何类型的二进制数据","application/octet-stream"), 12 BMP("bmp","Windows OS / 2位图图形","image/bmp"), 13 BZ("bz","BZip存档","application/x-bzip"), 14 BZ2("bz2","BZip2存档","application/x-bzip2"), 15 CSH("csh","C-Shell脚本","application/x-csh"), 16 CSS("css","级联样式表(CSS)","text/css"), 17 CSV("csv","逗号分隔值(CSV)","text/csv"), 18 DOC("doc","微软Word文件","application/msword"), 19 DOCX("docx","Microsoft Word(OpenXML)","application/vnd.openxmlformats-officedocument.wordprocessingml.document"), 20 EOT("eot","MS Embedded OpenType字体","application/vnd.ms-fontobject"), 21 EPUB("epub","电子出版物(EPUB)","application/epub+zip"), 22 GZ("gz","GZip压缩档案","application/gzip"), 23 GIF("gif","图形交换格式(GIF)","image/gif"), 24 HTM("htm","超文本标记语言(HTML)","text/html"), 25 HTML("html","超文本标记语言(HTML)","text/html"), 26 ICO("ico","图标格式","image/vnd.microsoft.icon"), 27 ICS("ics","iCalendar格式","text/calendar"), 28 JAR("jar","Java存档","application/java-archive"), 29 JPEG("jpeg","JPEG图像","image/jpeg"), 30 JPG("jpg","JPEG图像","image/jpeg"), 31 JS("js","JavaScript","text/javascript"), 32 JSON("json","JSON格式","application/json"), 33 JSONLD("jsonld","JSON-LD格式","application/ld+json"), 34 MID("mid","乐器数字接口(MIDI)","audio/midi"), 35 MIDI("midi","乐器数字接口(MIDI)","audio/midi"), 36 MJS("mjs","JavaScript模块","text/javascript"), 37 MP3("mp3","MP3音频","audio/mpeg"), 38 MPEG("mpeg","MPEG视频","video/mpeg"), 39 MPKG("mpkg","苹果安装程序包","application/vnd.apple.installer+xml"), 40 ODP("odp","OpenDocument演示文稿文档","application/vnd.oasis.opendocument.presentation"), 41 ODS("ods","OpenDocument电子表格文档","application/vnd.oasis.opendocument.spreadsheet"), 42 ODT("odt","OpenDocument文字文件","application/vnd.oasis.opendocument.text"), 43 OGA("oga","OGG音讯","audio/ogg"), 44 OGV("ogv","OGG视频","video/ogg"), 45 OGX("ogx","OGG","application/ogg"), 46 OPUS("opus","OPUS音频","audio/opus"), 47 OTF("otf","otf字体","font/otf"), 48 PNG("png","便携式网络图形","image/png"), 49 PDF("pdf","Adobe 可移植文档格式(PDF)","application/pdf"), 50 PHP("php","php","application/x-httpd-php"), 51 PPT("ppt","Microsoft PowerPoint","application/vnd.ms-powerpoint"), 52 PPTX("pptx","Microsoft PowerPoint(OpenXML)","application/vnd.openxmlformats-officedocument.presentationml.presentation"), 53 RAR("rar","RAR档案","application/vnd.rar"), 54 RTF("rtf","富文本格式","application/rtf"), 55 SH("sh","Bourne Shell脚本","application/x-sh"), 56 SVG("svg","可缩放矢量图形(SVG)","image/svg+xml"), 57 SWF("swf","小型Web格式(SWF)或Adobe Flash文档","application/x-shockwave-flash"), 58 TAR("tar","磁带存档(TAR)","application/x-tar"), 59 TIF("tif","标记图像文件格式(TIFF)","image/tiff"), 60 TIFF("tiff","标记图像文件格式(TIFF)","image/tiff"), 61 TS("ts","MPEG传输流","video/mp2t"), 62 TTF("ttf","ttf字体","font/ttf"), 63 TXT("txt","文本(通常为ASCII或ISO 8859- n","text/plain"), 64 VSD("vsd","微软Visio","application/vnd.visio"), 65 WAV("wav","波形音频格式","audio/wav"), 66 WEBA("weba","WEBM音频","audio/webm"), 67 WEBM("webm","WEBM视频","video/webm"), 68 WEBP("webp","WEBP图像","image/webp"), 69 WOFF("woff","Web开放字体格式(WOFF)","font/woff"), 70 WOFF2("woff2","Web开放字体格式(WOFF)","font/woff2"), 71 XHTML("xhtml","XHTML","application/xhtml+xml"), 72 XLS("xls","微软Excel","application/vnd.ms-excel"), 73 XLSX("xlsx","微软Excel(OpenXML)","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), 74 XML("xml","XML","application/xml"), 75 XUL("xul","XUL","application/vnd.mozilla.xul+xml"), 76 ZIP("zip","ZIP","application/zip"), 77 MIME_3GP("3gp", "3GPP audio/video container", "video/3gpp"), 78 MIME_3GP_WITHOUT_VIDEO("3gp", "3GPP audio/video container doesn't contain video", "audio/3gpp2"), 79 MIME_3G2("3g2", "3GPP2 audio/video container", "video/3gpp2"), 80 MIME_3G2_WITHOUT_VIDEO("3g2", "3GPP2 audio/video container doesn't contain video", "audio/3gpp2"), 81 MIME_7Z("7z","7-zip存档","application/x-7z-compressed") 82 ; 83 84 private String extension; 85 86 private String explain; 87 88 private String mimeType; 89 90 MimeTypeEnum(String extension, String explain, String mimeType) { 91 this.extension = extension; 92 this.explain = explain; 93 this.mimeType = mimeType; 94 } 95 96 public static MimeTypeEnum findByExtension(String extension) { 97 if(Objects.isNull(extension) || extension.length() == 0){ 98 return null; 99 } 100 for (MimeTypeEnum typesEnum : MimeTypeEnum.values()) { 101 if (extension.equals(typesEnum.getExtension())) { 102 return typesEnum; 103 } 104 } 105 return null; 106 } 107 108 /** 109 * Content-Type常用对照 110 * @param fileType 111 */ 112 public static String getContentType(String fileType) { 113 MimeTypeEnum mimeTypeEnum = MimeTypeEnum.findByExtension(fileType); 114 if(mimeTypeEnum != null){ 115 return mimeTypeEnum.getMimeType(); 116 } 117 return "application/octet-stream"; 118 } 119 120 public String getMimeType() { 121 return mimeType; 122 } 123 124 public String getExtension() { 125 return extension; 126 } 127 128 public String getExplain() { 129 return explain; 130 } 131 }
标签:vnd,String,image,对照,Content,application,video,audio,Type From: https://www.cnblogs.com/gzy2016Blog/p/17789160.html