Commit bcf431d7 authored by yanzg's avatar yanzg

SQL层级处理的支持

parent 168b544f
...@@ -16,14 +16,22 @@ public class FileHelper { ...@@ -16,14 +16,22 @@ public class FileHelper {
/** /**
* 获取文件类型 * 获取文件类型
* *
* @param file 来源文件 * @param filePath 来源文件
* @return * @return
* @throws IOException * @throws IOException
*/ */
public static String getMimeType(String file) throws IOException { public static String getMimeType(String filePath) {
Path path = Paths.get(file); File file = new File(filePath);
String contentType = contentType = Files.probeContentType(path); if (!file.exists()) {
return contentType; 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; package com.yanzuoguang.util;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.FileHelper; import com.yanzuoguang.util.helper.FileHelper;
import net.coobird.thumbnailator.Thumbnails; import net.coobird.thumbnailator.Thumbnails;
...@@ -37,7 +36,7 @@ public class ImageHelper { ...@@ -37,7 +36,7 @@ public class ImageHelper {
* @return * @return
* @throws IOException * @throws IOException
*/ */
public static int getMediaType(String file) throws IOException { public static int getMediaType(String file) {
String mimeType = FileHelper.getMimeType(file); String mimeType = FileHelper.getMimeType(file);
if (mimeType == null) { if (mimeType == null) {
throw new RuntimeException("不能识别文件类型" + file); 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