package api.xxx.com.upload.utils;
import cn.hutool.core.io.FileUtil;
/**
*
* @author Kelvin范显
* @createDate 2019年02月21日
*/
final public class FileTypeUtils{
/**
* 根据文件名获取文件类型
* @param filename
* @return
*/
public static String getContentTypeByFilename(String filename) {
return getContentTypeByExtName(FileUtil.extName(filename));
}
/**
* 根据文件后缀名获取文件类型
* @param extName
* @return
*/
public static String getContentTypeByExtName(String extName){
switch (extName){
case "jpeg": return "image/jpeg";
case "jpg": return "image/jpeg";
case "js": return "application/x-javascript";
case "jsp": return "text/html";
case "gif": return "image/gif";
case "htm": return "text/html";
case "html": return "text/html";
case "asf": return "video/x-ms-asf";
case "avi": return "video/avi";
case "bmp": return "application/x-bmp";
case "asp": return "text/asp";
case "wma": return "audio/x-ms-wma";
case "wav": return "audio/wav";
case "wmv": return "video/x-ms-wmv";
case "ra": return "audio/vnd.rn-realaudio";
case "ram": return "audio/x-pn-realaudio";
case "rm": return "application/vnd.rn-realmedia";
case "rmvb": return "application/vnd.rn-realmedia-vbr";
case "xhtml": return "text/html";
case "png": return "image/png";
case "tif": return "image/tiff";
case "tiff": return "image/tiff";
case "xlw": return "application/x-xlw";
case "xml": return "text/xml";
case "xpl": return "audio/scpls";
case "swf": return "application/x-shockwave-flash";
case "torrent": return "application/x-bittorrent";
case "dll": return "application/x-msdownload";
case "asa": return "text/asa";
case "asx": return "video/x-ms-asf";
case "au": return "audio/basic";
case "css": return "text/css";
case "exe": return "application/x-msdownload";
case "mp1": return "audio/mp1";
case "mp2": return "audio/mp2";
case "mp2v": return "video/mpeg";
case "mp3": return "audio/mp3";
case "mp4": return "video/mpeg4";
case "mpa": return "video/x-mpg";
case "mpd": return "application/vnd.ms-project";
case "mpe": return "video/x-mpeg";
case "mpeg": return "video/mpg";
case "mpg": return "video/mpg";
case "mpga": return "audio/rn-mpeg";
case "mpp": return "application/vnd.ms-project";
case "mps": return "video/x-mpeg";
case "mpt": return "application/vnd.ms-project";
case "mpv": return "video/mpg";
case "mpv2": return "video/mpeg";
case "wml": return "text/vnd.wap.wml";
case "wsdl": return "text/xml";
case "xsd": return "text/xml";
case "xsl": return "text/xml";
case "xslt": return "text/xml";
case "htc": return "text/x-component";
case "mdb": return "application/msaccess";
case "zip": return "application/zip";
case "rar": return "application/x-rar-compressed";
//BEGIN Microsoft Office MIME Types
case "doc": return "application/msword";
case "dot": return "application/msword";
case "docx": return "application/vndopenxmlformats-officedocumentwordprocessingmldocument";
case "dotx": return "application/vndopenxmlformats-officedocumentwordprocessingmltemplate";
case "docm": return "application/vndms-worddocumentmacroEnabled12";
case "dotm": return "application/vndms-wordtemplatemacroEnabled12";
case "xls": return "application/vndms-excel";
case "xlt": return "application/vndms-excel";
case "xla": return "application/vndms-excel";
case "xlsx": return "application/vndopenxmlformats-officedocumentspreadsheetmlsheet";
case "xltx": return "application/vndopenxmlformats-officedocumentspreadsheetmltemplate";
case "xlsm": return "application/vndms-excelsheetmacroEnabled12";
case "xltm": return "application/vndms-exceltemplatemacroEnabled12";
case "xlam": return "application/vndms-exceladdinmacroEnabled12";
case "xlsb": return "application/vndms-excelsheetbinarymacroEnabled12";
case "ppt": return "application/vndms-powerpoint";
case "pot": return "application/vndms-powerpoint";
case "pps": return "application/vndms-powerpoint";
case "ppa": return "application/vndms-powerpoint";
case "pptx": return "application/vndopenxmlformats-officedocumentpresentationmlpresentation";
case "potx": return "application/vndopenxmlformats-officedocumentpresentationmltemplate";
case "ppsx": return "application/vndopenxmlformats-officedocumentpresentationmlslideshow";
case "ppam": return "application/vndms-powerpointaddinmacroEnabled12";
case "pptm": return "application/vndms-powerpointpresentationmacroEnabled12";
case "potm": return "application/vndms-powerpointtemplatemacroEnabled12";
case "ppsm": return "application/vndms-powerpointslideshowmacroEnabled12";
//END Microsoft Office MIME Types
// others
case "*": return "application/octet-stream";
case "001": return "application/x-001";
case "301": return "application/x-301";
case "323": return "text/h323";
case "906": return "application/x-906";
case "907": return "drawing/907";
case "a11": return "application/x-a11";
case "acp": return "audio/x-mei-aac";
case "ai": return "application/postscript";
case "aif": return "audio/aiff";
case "aifc": return "audio/aiff";
case "aiff": return "audio/aiff";
case "anv": return "application/x-anv";
case "awf": return "application/vnd.adobe.workflow";
case "biz": return "text/xml";
case "bot": return "application/x-bot";
case "c4t": return "application/x-c4t";
case "c90": return "application/x-c90";
case "cal": return "application/x-cals";
case "cat": return "application/vnd.ms-pki.seccat";
case "cdf": return "application/x-netcdf";
case "cdr": return "application/x-cdr";
case "cel": return "application/x-cel";
case "cer": return "application/x-x509-ca-cert";
case "cg4": return "application/x-g4";
case "cgm": return "application/x-cgm";
case "cit": return "application/x-cit";
case "class": return "java/*";
case "cml": return "text/xml";
case "cmp": return "application/x-cmp";
case "cmx": return "application/x-cmx";
case "cot": return "application/x-cot";
case "crl": return "application/pkix-crl";
case "crt": return "application/x-x509-ca-cert";
case "csi": return "application/x-csi";
case "cut": return "application/x-cut";
case "dbf": return "application/x-dbf";
case "dbm": return "application/x-dbm";
case "dbx": return "application/x-dbx";
case "dcd": return "text/xml";
case "dcx": return "application/x-dcx";
case "der": return "application/x-x509-ca-cert";
case "dgn": return "application/x-dgn";
case "dib": return "application/x-dib";
case "drw": return "application/x-drw";
case "dtd": return "text/xml";
case "dwf": return "application/x-dwf";
case "dwg": return "application/x-dwg";
case "dxb": return "application/x-dxb";
case "dxf": return "application/x-dxf";
case "edn": return "application/vnd.adobe.edn";
case "emf": return "application/x-emf";
case "eml": return "message/rfc822";
case "ent": return "text/xml";
case "epi": return "application/x-epi";
case "eps": return "application/x-ps";
case "etd": return "application/x-ebx";
case "fax": return "image/fax";
case "fdf": return "application/vnd.fdf";
case "fif": return "application/fractals";
case "fo": return "text/xml";
case "frm": return "application/x-frm";
case "g4": return "application/x-g4";
case "gbr": return "application/x-gbr";
case "gcd": return "application/x-gcd";
case "gl2": return "application/x-gl2";
case "gp4": return "application/x-gp4";
case "hgl": return "application/x-hgl";
case "hmr": return "application/x-hmr";
case "hpg": return "application/x-hpgl";
case "hpl": return "application/x-hpl";
case "hqx": return "application/mac-binhex40";
case "hrf": return "application/x-hrf";
case "hta": return "application/hta";
case "htt": return "text/webviewhtml";
case "htx": return "text/html";
case "icb": return "application/x-icb";
case "ico": return "application/x-ico";
case "iff": return "application/x-iff";
case "ig4": return "application/x-g4";
case "igs": return "application/x-igs";
case "iii": return "application/x-iphone";
case "img": return "application/x-img";
case "ins": return "application/x-internet-signup";
case "isp": return "application/x-internet-signup";
case "IVF": return "video/x-ivf";
case "java": return "java/*";
case "jfif": return "image/jpeg";
case "jpe": return "application/x-jpe";
case "la1": return "audio/x-liquid-file";
case "lar": return "application/x-laplayer-reg";
case "latex": return "application/x-latex";
case "lavs": return "audio/x-liquid-secure";
case "lbm": return "application/x-lbm";
case "lmsff": return "audio/x-la-lms";
case "ls": return "application/x-javascript";
case "ltr": return "application/x-ltr";
case "m1v": return "video/x-mpeg";
case "m2v": return "video/x-mpeg";
case "m3u": return "audio/mpegurl";
case "m4e": return "video/mpeg4";
case "mac": return "application/x-mac";
case "man": return "application/x-troff-man";
case "math": return "text/xml";
case "mfp": return "application/x-shockwave-flash";
case "mht": return "message/rfc822";
case "mhtml": return "message/rfc822";
case "mi": return "application/x-mi";
case "mid": return "audio/mid";
case "midi": return "audio/mid";
case "mil": return "application/x-mil";
case "mml": return "text/xml";
case "mnd": return "audio/x-musicnet-download";
case "mns": return "audio/x-musicnet-stream";
case "mocha": return "application/x-javascript";
case "movie": return "video/x-sgi-movie";
case "mpw": return "application/vnd.ms-project";
case "mpx": return "application/vnd.ms-project";
case "mtx": return "text/xml";
case "mxp": return "application/x-mmxp";
case "net": return "image/pnetvue";
case "nrf": return "application/x-nrf";
case "nws": return "message/rfc822";
case "odc": return "text/x-ms-odc";
case "out": return "application/x-out";
case "p10": return "application/pkcs10";
case "p12": return "application/x-pkcs12";
case "p7b": return "application/x-pkcs7-certificates";
case "p7c": return "application/pkcs7-mime";
case "p7m": return "application/pkcs7-mime";
case "p7r": return "application/x-pkcs7-certreqresp";
case "p7s": return "application/pkcs7-signature";
case "pc5": return "application/x-pc5";
case "pci": return "application/x-pci";
case "pcl": return "application/x-pcl";
case "pcx": return "application/x-pcx";
case "pdf": return "application/pdf";
case "pdx": return "application/vnd.adobe.pdx";
case "pfx": return "application/x-pkcs12";
case "pgl": return "application/x-pgl";
case "pic": return "application/x-pic";
case "pko": return "application/vnd.ms-pki.pko";
case "pl": return "application/x-perl";
case "plg": return "text/html";
case "pls": return "audio/scpls";
case "plt": return "application/x-plt";
case "ppm": return "application/x-ppm";
case "pr": return "application/x-pr";
case "prf": return "application/pics-rules";
case "prn": return "application/x-prn";
case "prt": return "application/x-prt";
case "ps": return "application/x-ps";
case "ptn": return "application/x-ptn";
case "pwz": return "application/vnd.ms-powerpoint";
case "r3t": return "text/vnd.rn-realtext3d";
case "ras": return "application/x-ras";
case "rat": return "application/rat-file";
case "rdf": return "text/xml";
case "rec": return "application/vnd.rn-recording";
case "red": return "application/x-red";
case "rgb": return "application/x-rgb";
case "rjs": return "application/vnd.rn-realsystem-rjs";
case "rjt": return "application/vnd.rn-realsystem-rjt";
case "rlc": return "application/x-rlc";
case "rle": return "application/x-rle";
case "rmf": return "application/vnd.adobe.rmf";
case "rmi": return "audio/mid";
case "rmj": return "application/vnd.rn-realsystem-rmj";
case "rmm": return "audio/x-pn-realaudio";
case "rmp": return "application/vnd.rn-rn_music_package";
case "rms": return "application/vnd.rn-realmedia-secure";
case "rmx": return "application/vnd.rn-realsystem-rmx";
case "rnx": return "application/vnd.rn-realplayer";
case "rp": return "image/vnd.rn-realpix";
case "rpm": return "audio/x-pn-realaudio-plugin";
case "rsml": return "application/vnd.rn-rsml";
case "rt": return "text/vnd.rn-realtext";
case "rtf": return "application/msword";
case "rv": return "video/vnd.rn-realvideo";
case "sam": return "application/x-sam";
case "sat": return "application/x-sat";
case "sdp": return "application/sdp";
case "sdw": return "application/x-sdw";
case "sit": return "application/x-stuffit";
case "slb": return "application/x-slb";
case "sld": return "application/x-sld";
case "slk": return "drawing/x-slk";
case "smi": return "application/smil";
case "smil": return "application/smil";
case "smk": return "application/x-smk";
case "snd": return "audio/basic";
case "sol": return "text/plain";
case "sor": return "text/plain";
case "spc": return "application/x-pkcs7-certificates";
case "spl": return "application/futuresplash";
case "spp": return "text/xml";
case "ssm": return "application/streamingmedia";
case "sst": return "application/vnd.ms-pki.certstore";
case "stl": return "application/vnd.ms-pki.stl";
case "stm": return "text/html";
case "sty": return "application/x-sty";
case "svg": return "text/xml";
case "tdf": return "application/x-tdf";
case "tg4": return "application/x-tg4";
case "tga": return "application/x-tga";
case "tld": return "text/xml";
case "top": return "drawing/x-top";
case "tsd": return "text/xml";
case "txt": return "text/plain";
case "uin": return "application/x-icq";
case "uls": return "text/iuls";
case "vcf": return "text/x-vcard";
case "vda": return "application/x-vda";
case "vdx": return "application/vnd.visio";
case "vml": return "text/xml";
case "vpg": return "application/x-vpeg005";
case "vsd": return "application/vnd.visio";
case "vss": return "application/vnd.visio";
case "vst": return "application/vnd.visio";
case "vsw": return "application/vnd.visio";
case "vsx": return "application/vnd.visio";
case "vtx": return "application/vnd.visio";
case "vxml": return "text/xml";
case "wax": return "audio/x-ms-wax";
case "wb1": return "application/x-wb1";
case "wb2": return "application/x-wb2";
case "wb3": return "application/x-wb3";
case "wbmp": return "image/vnd.wap.wbmp";
case "wiz": return "application/msword";
case "wk3": return "application/x-wk3";
case "wk4": return "application/x-wk4";
case "wkq": return "application/x-wkq";
case "wks": return "application/x-wks";
case "wm": return "video/x-ms-wm";
case "wmd": return "application/x-ms-wmd";
case "wmf": return "application/x-wmf";
case "wmx": return "video/x-ms-wmx";
case "wmz": return "application/x-ms-wmz";
case "wp6": return "application/x-wp6";
case "wpd": return "application/x-wpd";
case "wpg": return "application/x-wpg";
case "wpl": return "application/vnd.ms-wpl";
case "wq1": return "application/x-wq1";
case "wr1": return "application/x-wr1";
case "wri": return "application/x-wri";
case "wrk": return "application/x-wrk";
case "ws": return "application/x-ws";
case "ws2": return "application/x-ws";
case "wsc": return "text/scriptlet";
case "wvx": return "video/x-ms-wvx";
case "xdp": return "application/vnd.adobe.xdp";
case "xdr": return "text/xml";
case "xfd": return "application/vnd.adobe.xfd";
case "xfdf": return "application/vnd.adobe.xfdf";
case "xq": return "text/xml";
case "xql": return "text/xml";
case "xquery": return "text/xml";
case "xwd": return "application/x-xwd";
case "x_b": return "application/x-x_b";
case "x_t": return "application/x-x_t";
}
return "application/octet-stream";
}
}
分享到:
相关推荐
1.文件类型工具类:FileTypeUtils 2.文件处理工具类:FileUtils 3.图片处理工具类:ImageUtils 4.媒体类型工具类:MimeTypeUtils 5.字符集工具类:CharsetKit 6.request请求处理工具类:CommonUtil 7.类型转换器:...
计算机发展与计算机应用概述.pdf
计算机二级公共基础知识全集合.pdf
计算机机试答案.pdf
内容概要:本文详细介绍了基于STM32F103RCT6的750W全桥逆变器设计方案,涵盖硬件电路设计、软件编程以及保护机制等方面。硬件部分包括主控芯片的选择、PWM配置、Boost升压电路、PCB布局优化等;软件部分涉及并离网切换的状态机设计、过流保护、风扇控制算法、并机功能实现等。文中还分享了许多实战经验和调试技巧,如死区时间配置、电流采样方法、并网同步算法等。 适合人群:具有一定电子电路和嵌入式开发基础的技术人员,尤其是从事逆变器及相关电力电子产品开发的工程师。 使用场景及目标:适用于希望深入了解逆变器工作原理和技术实现的开发者,特别是那些需要掌握并离网切换、高效电源管理及可靠保护机制的人群。目标是帮助读者构建一个稳定可靠的逆变器系统,能够应对各种复杂的工作环境。 其他说明:本文不仅提供了详细的理论讲解,还有丰富的代码片段和实践经验分享,有助于读者更好地理解和应用相关技术。
内容概要:本文详细介绍了如何利用Simulink在MATLAB环境中搭建单相全桥逆变器的仿真模型。首先,通过构建H桥结构,连接直流电源和RL负载,并引入PWM控制器进行开关管的控制。接着,针对仿真过程中遇到的各种问题,如谐波失真、开关管直通等问题,提出了具体的解决方案,包括加入LC滤波器、设置死区时间和优化PWM参数等。此外,还探讨了通过MATLAB脚本自动化测试不同参数组合的方法,以及如何提高电压利用率和降低谐波失真。最终,通过对仿真结果的分析,验证了所提方法的有效性和优越性。 适合人群:电力电子工程师、科研人员、高校学生等对逆变器仿真感兴趣的群体。 使用场景及目标:适用于研究和开发高效、稳定的逆变器系统,旨在通过仿真手段减少实验成本,优化设计方案,提高系统的性能指标。 其他说明:文中提供了详细的建模步骤和技术细节,帮助读者更好地理解和掌握相关技术和方法。同时,强调了仿真参数的选择和优化对于获得理想仿真结果的重要性。
计算机红外通信.pdf
软考考试学习必备资料.md
基于cornerstonejs开发移动端
构建交互式图片画廊
源码
Bosch Rexroth IndraWorks Ds IndraWorks Ds 14V16.310.0
java面向对象 - 类与对象
内容概要:本文详细介绍了基于AT32平台的无感FOC(Field-Oriented Control)控制算法,特别是针对永磁同步电机(PMSM)和无刷直流电机(BLDC)的位置速度观测器实现。文章首先展示了启动策略的独特之处,即跳过传统前馈强拖阶段,直接利用矢量控制环和观测器协同启动。接着深入探讨了磁链观测器的核心算法,包括磁链积分、反正切求角度以及速度估算部分使用的改良版PLL。此外,文中还提到了容差配置模块,用于提高系统的鲁棒性和稳定性。最后,强调了模块间良好的解耦设计,使得各功能模块拥有明确的输入输出接口,增强了代码的可维护性和移植性。 适合人群:从事电机控制系统开发的技术人员,尤其是对无感FOC算法感兴趣的工程师。 使用场景及目标:适用于需要高精度、快速响应的电机控制系统开发项目,旨在提升系统的鲁棒性和稳定性,特别是在电机参数存在偏差的情况下依然能够保持良好性能。 其他说明:文章不仅提供了详细的代码实现,还分享了许多实用的经验和技术细节,如启动策略、磁链观测器的物理本质、速度估算方法等,有助于读者更好地理解和应用无感FOC算法。
计算机机房de设置与维护.pdf
《Java 面试进阶指北 》 质量很高,专为面试打造
内容概要:本文详细介绍了外转子开关磁阻电机(ER-SRM)的多目标优化方法,主要采用NSGA-II算法进行优化。文章首先解释了为什么ER-SRM比传统内转子电机更难以优化,接着展示了如何利用NSGA-II算法解决这一难题。文中提供了详细的Matlab代码,包括种群初始化、交叉变异操作、非支配排序以及目标函数的定义。此外,还讨论了优化过程中的一些注意事项,如初始种群多样性的保持、交叉变异参数的选择、目标函数的设计等。最后,通过具体的案例和图表展示了优化结果及其应用价值。 适合人群:从事电机设计与优化的研究人员和技术人员,尤其是对外转子开关磁阻电机感兴趣的读者。 使用场景及目标:适用于需要同时优化电机效率、转矩波动和制造成本等多种目标的情况。通过NSGA-II算法,可以在多个相互冲突的目标间找到最佳平衡点,从而提高电机的整体性能。 其他说明:文章不仅提供了完整的Matlab代码实现,还分享了许多实践经验,如参数设置的经验公式、常见错误及解决方案等。这对于理解和掌握NSGA-II算法的实际应用非常有帮助。
慢行智远V2.0"是一款专业的串口数据采集与信号分析软件,集成了多通道数据采集、实时波形显示、FFT频谱分析、FIR滤波处理等高级功能。软件提供直观的用户界面,支持亮色/暗色两种主题,具备强大的数据处理与可视化能力。核心功能包括: 全面的串口通信支持(多种波特率、数据位、停止位、校验位配置) 多通道(最多4通道)波形实时显示与分析 高级信号处理(FFT频谱分析、FIR滤波、信号平滑等) 智能数据管理(断行数据处理、大数据量优化) 数据记录与导出(文本、CSV、图像多种格式) 自适应界面设计(支持高DPI显示、暗色主题) 适用人群 嵌入式开发工程师:需要通过串口调试单片机、开发板等嵌入式设备 电子工程师:进行电路测试、信号采集与分析的专业人员 工业自动化技术人员:监测工业设备数据、进行状态分析 科研教育工作者:用于实验数据采集、科学研究与教学演示 医疗设备开发人员:分析生物电信号、开发医疗监测设备 物联网开发者:调试传感器网络、分析传感器数据 硬件测试工程师:进行产品质量检测、性能评估 使用场景及目标 研发调试场景 单片机开发:实时监控传感器数据、调试通信协议、观察系统运行状态等等
计算机基础- 图.pdf
内容概要:本文详细介绍了如何利用MATLAB和YALMIP工具箱构建并优化孤岛微电网的混合整数线性规划(MILP)调度模型。主要内容涵盖模型搭建的关键步骤,如定义决策变量、设置约束条件(尤其是电池充放电互斥约束)、处理光伏出力预测、设定目标函数以及选择求解器参数。文中强调了模型的实际应用场景,即在光伏板发电、电池储能和用户用电之间寻找最佳平衡,确保最小化甩负荷和发电浪费。此外,作者分享了一些实用技巧,如通过调整甩负荷惩罚系数α来优化调度策略,以及如何有效配置GUROBI求解器以缩短计算时间。 适合人群:从事电力系统优化、微电网调度研究的专业人士,以及对混合整数线性规划感兴趣的科研人员和技术开发者。 使用场景及目标:适用于需要精确控制发电、储电和用电的孤岛微电网系统。目标是在满足用户电力需求的同时,最大化利用可再生能源,减少化石燃料消耗,并延长电池使用寿命。 其他说明:文中提供了大量MATLAB代码片段,帮助读者更好地理解和实现具体的建模方法。同时,作者还提到了一些常见的陷阱和优化建议,有助于提高模型性能和求解效率。