文件分片上传校验
This commit is contained in:
parent
5afd692c73
commit
598872f362
@ -39,6 +39,15 @@ public class ZhUploadSliceController {
|
||||
@RequestParam(value = "type") String type) {
|
||||
return zhUploadSliceService.uploadSlice(file, hash, filename, seq, type);
|
||||
}
|
||||
//文件分片数量校验
|
||||
@PostMapping("/checkMerge")
|
||||
public AjaxResult checkMerge(@RequestBody ZhFileMergeInfo mergeInfo) {
|
||||
String filename = mergeInfo.getFilename();
|
||||
String type = mergeInfo.getType();
|
||||
String hash = mergeInfo.getHash();
|
||||
Integer sliceCount = mergeInfo.getSliceCount();
|
||||
return zhUploadSliceService.checkMerge(filename, type, hash,sliceCount);
|
||||
}
|
||||
//合并文件
|
||||
@PostMapping("/merge")
|
||||
public AjaxResult merge(@RequestBody ZhFileMergeInfo mergeInfo) {
|
||||
|
||||
@ -36,6 +36,8 @@ public class ZhFileMergeInfo {
|
||||
private String filePath;
|
||||
/* 上传状态 (0:初始化,1:上传中,2:上传完成,3:上传失败) */
|
||||
private Integer uploadStatus;
|
||||
/* 分片总数量 */
|
||||
private Integer sliceCount;
|
||||
/* 上传时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private String uploadTime;
|
||||
|
||||
@ -76,7 +76,8 @@ public class ZhUploadSliceServiceImpl extends ServiceImpl<ZhFileMergeInfoMapper,
|
||||
AjaxResult resp = new AjaxResult();
|
||||
String uploadPathMerge = uploadPath+"uploadSlice/";
|
||||
JSONObject mergeResult = UploadSliceUtil.checkMerge(filename, type, hash, sliceCount, uploadPathMerge);
|
||||
resp.put("code", mergeResult.getBoolean("success") ? 200 : 500);
|
||||
//resp.put("code", mergeResult.getBoolean("success") ? 200 : 500);
|
||||
resp.put("code", 200);
|
||||
resp.put("deSlice",mergeResult.getJSONArray("deSlice"));
|
||||
return resp;
|
||||
}
|
||||
@ -90,7 +91,7 @@ public class ZhUploadSliceServiceImpl extends ServiceImpl<ZhFileMergeInfoMapper,
|
||||
public AjaxResult uploadMerge(String filename, String type, String hash){
|
||||
String uploadPathMerge = uploadPath+"uploadSlice/";
|
||||
JSONObject mergeResult = UploadSliceUtil.uploadMerge(filename, type, hash, uploadPathMerge);
|
||||
ZhFileMergeInfo zhFileMergeInfo = new ZhFileMergeInfo(null, filename,type, hash, null, 0, DateUtils.getCurrentTimeToString());
|
||||
ZhFileMergeInfo zhFileMergeInfo = new ZhFileMergeInfo(null, filename,type, hash, null, 0,null, DateUtils.getCurrentTimeToString());
|
||||
AjaxResult resp = new AjaxResult();
|
||||
resp.put("msg",mergeResult.getString("msg"));
|
||||
if (mergeResult.getBoolean("success")) {
|
||||
|
||||
@ -90,6 +90,7 @@ public class UploadSliceUtil {
|
||||
deSlice.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
resp.put("success",deSlice.size()>0 ? false : true);
|
||||
resp.put("deSlice",deSlice);
|
||||
return resp;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user