|
@@ -2,7 +2,6 @@ package cn.com.qmth.examcloud.support.fss;
|
|
|
|
|
|
import org.apache.commons.codec.binary.Hex;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
-import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -67,6 +66,7 @@ public class FssHelper {
|
|
|
public static String getFileName(String filePath) {
|
|
|
if (filePath != null) {
|
|
|
filePath = filePath.replace("\\", "/");
|
|
|
+
|
|
|
int index = filePath.lastIndexOf("/");
|
|
|
if (index >= 0) {
|
|
|
return filePath.substring(index + 1);
|
|
@@ -80,10 +80,6 @@ public class FssHelper {
|
|
|
* 获取文件MD5值
|
|
|
*/
|
|
|
public static String getFileMD5(byte[] fileBytes) {
|
|
|
- if (ArrayUtils.isEmpty(fileBytes)) {
|
|
|
- throw new RuntimeException("文件大小不能为空!");
|
|
|
- }
|
|
|
-
|
|
|
return DigestUtils.md5Hex(fileBytes);
|
|
|
}
|
|
|
|
|
@@ -94,8 +90,9 @@ public class FssHelper {
|
|
|
if (file == null) {
|
|
|
throw new RuntimeException("文件不能为空!");
|
|
|
}
|
|
|
+
|
|
|
if (!file.isFile()) {
|
|
|
- throw new RuntimeException("文件类型不能正确!");
|
|
|
+ throw new RuntimeException("文件类型错误!");
|
|
|
}
|
|
|
|
|
|
try (FileInputStream fis = new FileInputStream(file);) {
|