package cn.huge.base.common.utils;
|
|
|
/**
|
* @title: 请求响应操作类
|
* @description: 请求响应操作类
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2021-11-05 16:51:48
|
* @version: 1.0.0
|
*/
|
public class ContentTypeUtils {
|
|
/**
|
* 通过文件名判断并获取文件的contentType
|
*
|
* @param suffix
|
* @return
|
*/
|
public static final String getContentType(String suffix) {
|
if (suffix.equalsIgnoreCase("bmp")) {
|
return "application/x-bmp";
|
}
|
if (suffix.equalsIgnoreCase("gif")) {
|
return "image/gif";
|
}
|
if (suffix.equalsIgnoreCase("jpeg") ||
|
suffix.equalsIgnoreCase("jpg") ||
|
suffix.equalsIgnoreCase("png")) {
|
return "image/jpeg";
|
}
|
if (suffix.equalsIgnoreCase("html")) {
|
return "text/html";
|
}
|
if (suffix.equalsIgnoreCase("txt")) {
|
return "text/plain";
|
}
|
if (suffix.equalsIgnoreCase("vsd")) {
|
return "application/vnd.visio";
|
}
|
if (suffix.equalsIgnoreCase("pptx") ||
|
suffix.equalsIgnoreCase("ppt")) {
|
return "application/vnd.ms-powerpoint";
|
}
|
if (suffix.equalsIgnoreCase("docx") ||
|
suffix.equalsIgnoreCase("doc")) {
|
return "application/msword";
|
}
|
if (suffix.equalsIgnoreCase("xla") ||
|
suffix.equalsIgnoreCase("xlc")||
|
suffix.equalsIgnoreCase("xlm")||
|
suffix.equalsIgnoreCase("xls")||
|
suffix.equalsIgnoreCase("xlt")||
|
suffix.equalsIgnoreCase("xlw")) {
|
return "application/vnd.ms-excel";
|
}
|
if (suffix.equalsIgnoreCase("xml")) {
|
return "text/xml";
|
}
|
if (suffix.equalsIgnoreCase("pdf")) {
|
return "application/pdf";
|
}
|
if (suffix.equalsIgnoreCase("zip")) {
|
return "application/zip";
|
}
|
if (suffix.equalsIgnoreCase("tar")) {
|
return "application/x-tar";
|
}
|
if (suffix.equalsIgnoreCase("avi")) {
|
return "video/avi";
|
}
|
if (suffix.equalsIgnoreCase("mp4")) {
|
return "video/mpeg4";
|
}
|
if (suffix.equalsIgnoreCase("mp3")) {
|
return "audio/mp3";
|
}
|
if (suffix.equalsIgnoreCase("mp2")) {
|
return "audio/mp2";
|
}
|
return "application/octet-stream";
|
}
|
}
|
/**
|
* -------------------_ooOoo_-------------------
|
* ------------------o8888888o------------------
|
* ------------------88" . "88------------------
|
* ------------------(| -_- |)------------------
|
* ------------------O\ = /O------------------
|
* ---------------____/`---'\____---------------
|
* -------------.' \\| |// `.-------------
|
* ------------/ \\||| : |||// \------------
|
* -----------/ _||||| -:- |||||- \-----------
|
* -----------| | \\\ - /// | |-----------
|
* -----------| \_| ''\---/'' | |-----------
|
* -----------\ .-\__ `-` ___/-. /-----------
|
* ---------___`. .' /--.--\ `. . __----------
|
* ------."" '< `.___\_<|>_/___.' >'"".-------
|
* -----| | : `- \`.;`\ _ /`;.`/ - ` : | |-----
|
* -----\ \ `-. \_ __\ /__ _/ .-` / /-----
|
* ======`-.____`-.___\_____/___.-`____.-'======
|
* -------------------`=---='
|
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
* ---------佛祖保佑---hugeinfo---永无BUG----------
|
*/
|