MCPcopy Create free account
hub / github.com/Hello-hao/Tbed / FileMiME

Method FileMiME

src/main/java/cn/hellohao/utils/TypeDict.java:15–35  ·  view source on GitHub ↗
(InputStream stream)

Source from the content-addressed store, hash-verified

13
14 //apache大法
15 public static Msg FileMiME(InputStream stream){
16 final Msg msg = new Msg();
17 try {
18 Tika tika = new Tika();
19 String fileType = tika.detect(stream);
20 if (fileType != null && fileType.contains("/")) {
21 if(fileType.contains("image/")){
22 msg.setData(fileType);
23 }else{
24 //非图像类型
25 msg.setCode("110602");
26 msg.setInfo("该文件非图像文件,或不受支持");
27 }
28 }
29 } catch (Exception e) {
30 System.err.println("这是一个图像类别鉴定的报错:161");
31 msg.setCode("110603");//图像格式不受支持
32 msg.setInfo("暂时不能上传该文件");
33 }
34 return msg;
35 }
36
37
38

Callers 5

downLoadFromUrlMethod · 0.95
uploadForLocMethod · 0.95
ImageuploadOSSMethod · 0.95
uploadImgMethod · 0.95
ImageuploadUSSMethod · 0.95

Calls 3

setDataMethod · 0.95
setCodeMethod · 0.95
setInfoMethod · 0.95

Tested by

no test coverage detected