Commit bcf431d7 authored by yanzg's avatar yanzg

SQL层级处理的支持

parent 168b544f
......@@ -16,14 +16,22 @@ public class FileHelper {
/**
* 获取文件类型
*
* @param file 来源文件
* @param filePath 来源文件
* @return
* @throws IOException
*/
public static String getMimeType(String file) throws IOException {
Path path = Paths.get(file);
String contentType = contentType = Files.probeContentType(path);
return contentType;
public static String getMimeType(String filePath) {
File file = new File(filePath);
if (!file.exists()) {
return StringHelper.EMPTY;
}
Path path = Paths.get(filePath);
try {
String contentType = Files.probeContentType(path);
return contentType;
} catch (Exception ex) {
throw new RuntimeException("不能获取文件Mime类型" + filePath, ex);
}
}
/**
......
package com.yanzuoguang.util;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.FileHelper;
import net.coobird.thumbnailator.Thumbnails;
......@@ -37,7 +36,7 @@ public class ImageHelper {
* @return
* @throws IOException
*/
public static int getMediaType(String file) throws IOException {
public static int getMediaType(String file) {
String mimeType = FileHelper.getMimeType(file);
if (mimeType == null) {
throw new RuntimeException("不能识别文件类型" + file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment