package cn.besteam.common.constant;
|
|
import lombok.Getter;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* @author Kinsey Huang
|
* @email 996842803@qq.com
|
* @date 2019/4/1 1:09 PM
|
* @Describe oss类型(文件类型 < - - - > 上传类型)
|
*/
|
public enum OssTypeEM {//找不到文件类型
|
|
Empty("empty", null)
|
//bmp文件
|
, BMP("bmp", "image/bmp")
|
//gif文件
|
, GIF("gif", "image/gif")
|
//jpeg文件
|
, JPEG("jpeg", "image/jpeg")
|
//jpg文件
|
, JPG("jpg", "image/jpeg")
|
//png文件
|
, PNG("png", "image/png")
|
//html文件
|
, HTML("html", "text/html")
|
//txt文件
|
, TXT("txt", "text/plain")
|
//pptx文件
|
, PPTX("pptx", "application/vnd.ms-powerpoint")
|
//ppt文件
|
, PPT("ppt", "application/vnd.ms-powerpoint")
|
//docx文件
|
, DOCX("docx", "application/msword")
|
//doc文件
|
, DOC("doc", "application/msword")
|
//xml文件
|
, XML("xml", "text/xml")
|
//mp3文件
|
, MP3("mp3", "audio/mpeg"), MP4("mp4", "video/mpeg4");
|
|
/**
|
* 文件类型
|
*/
|
@Getter
|
private String fileType;
|
|
/**
|
* 上传类型
|
*/
|
@Getter
|
private String contentType;
|
|
OssTypeEM(String fileType, String contentType) {
|
|
this.fileType = fileType;
|
this.contentType = contentType;
|
}
|
|
/**
|
* 存储所有此类型枚举
|
*/
|
public static final Map<String, OssTypeEM> MAP = new HashMap<>();
|
|
static {
|
for (OssTypeEM item : OssTypeEM.values()) {
|
MAP.put(item.fileType, item);
|
}
|
}
|
|
/**
|
* @param fileType 文件类型
|
* @return 对应的枚举实例
|
* @Describe 根据文件类型获取对应oss类型
|
*/
|
public static OssTypeEM getByFileType(String fileType) {
|
|
return MAP.getOrDefault(fileType, OssTypeEM.Empty);
|
}}
|