|
|
@@ -3,8 +3,6 @@ package com.zd.base.files.bigupload.service.impl;
|
|
|
|
|
|
import com.zd.base.files.bigupload.dto.FileChunkDTO;
|
|
|
import com.zd.base.files.bigupload.dto.FileChunkResultDTO;
|
|
|
-import com.zd.base.files.bigupload.response.error.BusinessErrorCode;
|
|
|
-import com.zd.base.files.bigupload.response.error.BusinessException;
|
|
|
import com.zd.base.files.bigupload.service.IUploadService;
|
|
|
import com.zd.base.files.bigupload.utils.FileUtils;
|
|
|
import com.zd.base.files.file.config.ResourcesConfig;
|
|
|
@@ -18,6 +16,7 @@ import org.springframework.util.StringUtils;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.*;
|
|
|
import java.net.UnknownHostException;
|
|
|
+import java.rmi.ServerException;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@@ -45,7 +44,7 @@ public class UploadServiceImpl implements IUploadService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) throws BusinessException {
|
|
|
+ public FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) {
|
|
|
//1.检查文件是否已上传过
|
|
|
//1.1)检查在磁盘中是否存在
|
|
|
String fileFolderPath = getFileFolderPath(chunkDTO.getIdentifier());
|
|
|
@@ -74,7 +73,7 @@ public class UploadServiceImpl implements IUploadService {
|
|
|
* @param chunkDTO
|
|
|
*/
|
|
|
@Override
|
|
|
- public void uploadChunk(FileChunkDTO chunkDTO) throws BusinessException {
|
|
|
+ public void uploadChunk(FileChunkDTO chunkDTO) throws ServerException {
|
|
|
//分块的目录
|
|
|
String chunkFileFolderPath = getChunkFileFolderPath(chunkDTO.getIdentifier());
|
|
|
logger.info("分块的目录 -> {}", chunkFileFolderPath);
|
|
|
@@ -93,13 +92,13 @@ public class UploadServiceImpl implements IUploadService {
|
|
|
//将该分片写入redis
|
|
|
long size = saveToRedis(chunkDTO);
|
|
|
} catch (Exception e) {
|
|
|
- throw new BusinessException(BusinessErrorCode.INVALID_PARAMETER, e.getMessage());
|
|
|
+ throw new ServerException("参数错误" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public String mergeChunk(String identifier, String fileName, Integer totalChunks) throws BusinessException, IOException {
|
|
|
+ public String mergeChunk(String identifier, String fileName, Integer totalChunks) throws IOException {
|
|
|
String suffix = fileName.substring(fileName.lastIndexOf("."));
|
|
|
if(null==suffix){
|
|
|
throw new RuntimeException("文件格式有误");
|