其他分享
首页 > 其他分享> > 2021-10-14

2021-10-14

作者:互联网

MultipartFile的getContentType文件类型


最近搞得东西涉及到文件类型,分享一下

  switch (fileExt)
            {
                case ".doc":
                    return "application/msword";
                case "docx":
                    return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                case ".rtf":
                    return "application/rtf";
                case ".xls":
                    return "application/vnd.ms-excel";
                case ".xlsx":
                    return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                case ".ppt":
                    return "application/vnd.ms-powerpoint";
                case ".pptx":
                    return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
                case ".pdf":
                    return "application/pdf";
                case ".swf":
                    return "application/x-shockwave-flash";
                case ".rar":
                    return "application/octet-stream";
                case ".zip":
                    return "application/x-zip-compressed";
                case ".mp3":
                    return "audio/mpeg";
                case ".gif":
                    return "image/gif";
                case ".png":
                    return "image/png";
                case ".jpeg":
                    return "image/jpeg";
                case ".jpg":
                    return "image/jpeg";
                case ".jpe":
                    return "image/jpeg";
                case ".txt":
                    return "text/plain";
                case ".bmp":
                    return "image/jpeg";
                case ".exe":
                    return "application/octet-stream";

                default:
                    return "application/octet-stream";

            }

标签:case,10,vnd,return,14,image,jpeg,application,2021
来源: https://blog.csdn.net/m0_50887920/article/details/120774544