|
@@ -1,15 +1,14 @@
|
|
|
package com.qmth.boot.core.fss.store.impl;
|
|
|
|
|
|
import com.qmth.boot.core.fss.store.FileStore;
|
|
|
-import com.qmth.boot.tools.codec.CodecUtils;
|
|
|
import com.qmth.boot.tools.io.IOUtils;
|
|
|
+import com.qmth.boot.tools.models.ByteArray;
|
|
|
import com.qmth.boot.tools.uuid.FastUUID;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.InputStream;
|
|
|
-import java.security.MessageDigest;
|
|
|
|
|
|
/**
|
|
|
* 本地磁盘文件管理工具
|
|
@@ -53,15 +52,20 @@ public class DiskStore implements FileStore {
|
|
|
//临时目录创建临时文件
|
|
|
File tempFile = new File(tempDir, FastUUID.get());
|
|
|
try {
|
|
|
- final MessageDigest digest = CodecUtils.getMd5();
|
|
|
+ //final MessageDigest digest = CodecUtils.getMd5();
|
|
|
FileOutputStream ous = new FileOutputStream(tempFile);
|
|
|
- IOUtils.copy(ins, ous, (buffer, length) -> digest.update(buffer, 0, length));
|
|
|
+ IOUtils.copy(ins, ous);
|
|
|
+ //IOUtils.copy(ins, ous, (buffer, length) -> digest.update(buffer, 0, length));
|
|
|
//校验写入内容的摘要信息
|
|
|
- if (!CodecUtils.toBase64(digest.digest()).equalsIgnoreCase(toBase64(md5))) {
|
|
|
- throw new RuntimeException("Write md5 validate faile");
|
|
|
- }
|
|
|
+ //if (!CodecUtils.toBase64(digest.digest()).equalsIgnoreCase(toBase64(md5))) {
|
|
|
+ //throw new RuntimeException("Write md5 validate faile");
|
|
|
+ //}
|
|
|
IOUtils.closeQuietly(ins);
|
|
|
IOUtils.closeQuietly(ous);
|
|
|
+ //校验写入内容的摘要信息
|
|
|
+ if (!ByteArray.md5(tempFile).toBase64().equalsIgnoreCase(toBase64(md5))) {
|
|
|
+ throw new RuntimeException("Write md5 validate faile");
|
|
|
+ }
|
|
|
//检查正式文件及目录
|
|
|
File targetFile = new File(rootDir, path);
|
|
|
if (targetFile.isDirectory()) {
|