1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| package com.example.minioserver.enums;
import cn.hutool.core.util.StrUtil;
public enum ViewContentType {
DEFAULT("default","application/octet-stream"), JPG("jpg", "image/jpeg"), TIFF("tiff", "image/tiff"), GIF("gif", "image/gif"), JFIF("jfif", "image/jpeg"), PNG("png", "image/png"), TIF("tif", "image/tiff"), ICO("ico", "image/x-icon"), JPEG("jpeg", "image/jpeg"), WBMP("wbmp", "image/vnd.wap.wbmp"), FAX("fax", "image/fax"), NET("net", "image/pnetvue"), JPE("jpe", "image/jpeg"), RP("rp", "image/vnd.rn-realpix");
private String prefix;
private String type;
public static String getContentType(String prefix){ if(StrUtil.isEmpty(prefix)){ return DEFAULT.getType(); } prefix = prefix.substring(prefix.lastIndexOf(".") + 1); for (ViewContentType value : ViewContentType.values()) { if(prefix.equalsIgnoreCase(value.getPrefix())){ return value.getType(); } } return DEFAULT.getType(); }
ViewContentType(String prefix, String type) { this.prefix = prefix; this.type = type; }
public String getPrefix() { return prefix; }
public String getType() { return type; }
}
|