|
|
@@ -5,6 +5,7 @@ import com.zd.base.files.bigupload.dto.FileChunkDTO;
|
|
|
import com.zd.base.files.bigupload.dto.FileChunkResultDTO;
|
|
|
import com.zd.base.files.bigupload.service.IUploadService;
|
|
|
import com.zd.model.domain.ResultData;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -15,13 +16,14 @@ import org.springframework.web.bind.annotation.*;
|
|
|
**/
|
|
|
@RestController
|
|
|
@RequestMapping("/file/upload")
|
|
|
+@Slf4j
|
|
|
public class UploadController {
|
|
|
|
|
|
@Autowired
|
|
|
private IUploadService uploadService;
|
|
|
|
|
|
/**
|
|
|
- * 检查分片是否存在
|
|
|
+ * 检查分片是否存��
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -37,6 +39,32 @@ public class UploadController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 检查分片是否存
|
|
|
+ * @param identifier 文件秘钥
|
|
|
+ * @param filename 文件
|
|
|
+ * @param totalChunks 分片总数
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/apk/chunk")
|
|
|
+ public ResultData<Object> checkChunkExist(@RequestParam("identifier") String identifier,
|
|
|
+ @RequestParam("filename") String filename,
|
|
|
+ @RequestParam("totalChunks") Integer totalChunks) {
|
|
|
+ FileChunkResultDTO fileChunkCheckDTO;
|
|
|
+ try {
|
|
|
+ log.info("apk文件上传入参 identifier {}filename {}, totalChunks {}", identifier, filename, totalChunks);
|
|
|
+ FileChunkDTO chunkDTO = new FileChunkDTO();
|
|
|
+ chunkDTO.setIdentifier(identifier);
|
|
|
+ chunkDTO.setFilename(filename);
|
|
|
+ chunkDTO.setTotalChunks(totalChunks);
|
|
|
+ fileChunkCheckDTO = uploadService.checkChunkExist(chunkDTO);
|
|
|
+ return ResultData.success(fileChunkCheckDTO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return ResultData.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* 上传文件分片
|
|
|
*
|
|
|
* @param chunkDTO
|
|
|
@@ -53,6 +81,22 @@ public class UploadController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 上传文件分片
|
|
|
+ *
|
|
|
+ * @param chunkDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/apk/chunk")
|
|
|
+ public ResultData<Object> uploadChunkByAPK(@RequestBody FileChunkDTO chunkDTO) {
|
|
|
+ try {
|
|
|
+ uploadService.uploadChunk(chunkDTO);
|
|
|
+ return ResultData.success(chunkDTO.getIdentifier());
|
|
|
+ } catch (Exception e) {
|
|
|
+ return ResultData.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 请求合并文件分片
|
|
|
*
|
|
|
* @param chunkDTO
|