Browse Source

sha1 and md5

master
zhizhi wu 6 years ago
parent
commit
8a03302e96
  1. 19
      src/main/java/com/ccsens/filedeal/api/DebugController.java
  2. 2
      src/main/java/com/ccsens/filedeal/api/FileController.java
  3. 8
      src/main/java/com/ccsens/filedeal/bean/vo/FileVo.java
  4. 8
      src/main/java/com/ccsens/filedeal/service/FileService.java

19
src/main/java/com/ccsens/filedeal/api/DebugController.java

@ -0,0 +1,19 @@
package com.ccsens.filedeal.api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description:
* @author: whj
* @time: 2020/9/22 10:25
*/
@RestController
@RequestMapping("debug")
public class DebugController {
@RequestMapping("/")
public String index(){
return "hello world";
}
}

2
src/main/java/com/ccsens/filedeal/api/FileController.java

@ -47,8 +47,6 @@ public class FileController {
@RequestMapping(value = "upload/bigFile", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<FileVo.BigFile> uploadBigFile(FileDto.MultipartFileUpload fileUpload) throws Exception {
log.info("大文件上传:{}", fileUpload);
String dir = PropUtil.path + WebConstant.FILE_UPLOAD_DIR;
FileVo.BigFile bigFile = fileService.uploadBigFile(fileUpload);
log.info("大文件上传返回:{}", bigFile);
return JsonResponse.newInstance().ok(bigFile);

8
src/main/java/com/ccsens/filedeal/bean/vo/FileVo.java

@ -57,12 +57,8 @@ public class FileVo {
private int chunkNum;
@ApiModelProperty("文件sha1字符串")
private String sha1;
// @ApiModelProperty("上传文件id")
// private Long id;
// @ApiModelProperty("文件名")
// private String name;
// @ApiModelProperty("存储路径")
// private String path;
@ApiModelProperty("文件md5字符串")
private String md5;
}

8
src/main/java/com/ccsens/filedeal/service/FileService.java

@ -279,7 +279,9 @@ public class FileService extends AbstractRedisService implements IFileService {
log.info("文件块已上传");
bigFile.setResult(WebConstant.FileMsg.FILE_UPLOAD_READY);
//文件sha1
bigFile.setSha1(Sha1Util.getFileSha1(new File(path)));
File file1 = new File(path);
bigFile.setSha1(Sha1Util.getFileSha1(file1));
bigFile.setMd5(Md5Util.getFileMD5(file1));
return bigFile;
}
}
@ -337,7 +339,9 @@ public class FileService extends AbstractRedisService implements IFileService {
}
}
}
bigFile.setSha1(Sha1Util.getFileSha1(new File(path)));
File file1 = new File(path);
bigFile.setSha1(Sha1Util.getFileSha1(file1));
bigFile.setMd5(Md5Util.getFileMD5(file1));
bigFile.setResult(WebConstant.FileMsg.FILE_UPLOAD_SUC);
log.info("响应时间:{}", System.currentTimeMillis() - t1);
return bigFile;

Loading…
Cancel
Save