package com.skr.mdm.util.upload;

/**
 * @ProjectName: mdm_new
 * @Package: utils
 * @ClassName: CommonUtil
 * @Author: Tty
 * @Description: 文件类型解析
 * @Date: 2021/2/26 11:06
 * @Version: 1.0
 */
public class CommonUtil {
	public static String setContentType(String returnFileName) {
		String contentType = "application/octet-stream";
		if (returnFileName.lastIndexOf(".") < 0) {
			return contentType;
		}
		returnFileName = returnFileName.toLowerCase();
		returnFileName = returnFileName.substring(returnFileName.lastIndexOf(".") + 1);
		switch (returnFileName) {
			case "html":
			case "htm":
			case "shtml":
				contentType = "text/html";
				break;
			case "apk":
				contentType = "application/vnd.android.package-archive";
				break;
			case "sis":
				contentType = "application/vnd.symbian.install";
				break;
			case "sisx":
				contentType = "application/vnd.symbian.install";
				break;
			case "exe":
				contentType = "application/x-msdownload";
				break;
			case "msi":
				contentType = "application/x-msdownload";
				break;
			case "css":
				contentType = "text/css";
				break;
			case "xml":
				contentType = "text/xml";
				break;
			case "gif":
				contentType = "image/gif";
				break;
			case "jpeg":
			case "jpg":
				contentType = "image/jpeg";
				break;
			case "js":
				contentType = "application/x-javascript";
				break;
			case "atom":
				contentType = "application/atom+xml";
				break;
			case "rss":
				contentType = "application/rss+xml";
				break;
			case "mml":
				contentType = "text/mathml";
				break;
			case "txt":
				contentType = "text/plain";
				break;
			case "jad":
				contentType = "text/vnd.sun.j2me.app-descriptor";
				break;
			case "wml":
				contentType = "text/vnd.wap.wml";
				break;
			case "htc":
				contentType = "text/x-component";
				break;
			case "png":
				contentType = "image/png";
				break;
			case "tif":
			case "tiff":
				contentType = "image/tiff";
				break;
			case "wbmp":
				contentType = "image/vnd.wap.wbmp";
				break;
			case "ico":
				contentType = "image/x-icon";
				break;
			case "jng":
				contentType = "image/x-jng";
				break;
			case "bmp":
				contentType = "image/x-ms-bmp";
				break;
			case "svg":
				contentType = "image/svg+xml";
				break;
			case "jar":
			case "var":
			case "ear":
				contentType = "application/java-archive";
				break;
			case "doc":
				contentType = "application/msword";
				break;
			case "pdf":
				contentType = "application/pdf";
				break;
			case "rtf":
				contentType = "application/rtf";
				break;
			case "xls":
				contentType = "application/vnd.ms-excel";
				break;
			case "ppt":
				contentType = "application/vnd.ms-powerpoint";
				break;
			case "7z":
				contentType = "application/x-7z-compressed";
				break;
			case "rar":
				contentType = "application/x-rar-compressed";
				break;
			case "swf":
				contentType = "application/x-shockwave-flash";
				break;
			case "rpm":
				contentType = "application/x-redhat-package-manager";
				break;
			case "der":
			case "pem":
			case "crt":
				contentType = "application/x-x509-ca-cert";
				break;
			case "xhtml":
				contentType = "application/xhtml+xml";
				break;
			case "zip":
				contentType = "application/zip";
				break;
			case "mid":
			case "midi":
			case "kar":
				contentType = "audio/midi";
				break;
			case "mp3":
				contentType = "audio/mpeg";
				break;
			case "ogg":
				contentType = "audio/ogg";
				break;
			case "m4a":
				contentType = "audio/x-m4a";
				break;
			case "ra":
				contentType = "audio/x-realaudio";
				break;
			case "3gpp":
			case "3gp":
				contentType = "video/3gpp";
				break;
			case "mp4":
				contentType = "video/mp4";
				break;
			case "mpeg":
			case "mpg":
				contentType = "video/mpeg";
				break;
			case "mov":
				contentType = "video/quicktime";
				break;
			case "flv":
				contentType = "video/x-flv";
				break;
			case "m4v":
				contentType = "video/x-m4v";
				break;
			case "mng":
				contentType = "video/x-mng";
				break;
			case "asx":
			case "asf":
				contentType = "video/x-ms-asf";
				break;
			case "wmv":
				contentType = "video/x-ms-wmv";
				break;
			case "avi":
				contentType = "video/x-msvideo";
				break;
		}
		return contentType;
	}
}
