|
@@ -75,33 +75,39 @@ public class BoxModelServiceImpl implements IBoxModelService {
|
|
|
String zipPath = path + file.getOriginalFilename();
|
|
|
String srcPath = path + "data/";
|
|
|
String glbPath = path + sid + ".glb";
|
|
|
- FileUtil.mkParentDirs(zipPath);
|
|
|
- file.transferTo(new File(zipPath));
|
|
|
-
|
|
|
- //解压
|
|
|
- FileUtils.decompress(zipPath, srcPath);
|
|
|
-
|
|
|
- //校验是否包含目录,如果包含目录提示错误
|
|
|
- List<String> fileList = com.fdkankan.common.util.FileUtil.getFileList(srcPath);
|
|
|
- if(CollUtil.isNotEmpty(fileList)){
|
|
|
- fileList.stream().forEach(str -> {
|
|
|
- if(FileUtil.isDirectory(str)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5065);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
- //转glb
|
|
|
- OBJToGLBUtil.objToGlb(srcPath, glbPath);
|
|
|
+ try{
|
|
|
+ FileUtil.del(path);
|
|
|
+ FileUtil.mkParentDirs(zipPath);
|
|
|
+ file.transferTo(new File(zipPath));
|
|
|
|
|
|
- if(!FileUtil.exist(glbPath)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
- }
|
|
|
+ //解压
|
|
|
+ FileUtils.decompress(zipPath, srcPath);
|
|
|
+
|
|
|
+ //校验是否包含目录,如果包含目录提示错误
|
|
|
+ List<String> fileList = com.fdkankan.common.util.FileUtil.getFileList(srcPath);
|
|
|
+ if(CollUtil.isNotEmpty(fileList)){
|
|
|
+ fileList.stream().forEach(str -> {
|
|
|
+ if(FileUtil.isDirectory(str)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5065);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //转glb
|
|
|
+ OBJToGLBUtil.objToGlb(srcPath, glbPath);
|
|
|
|
|
|
- //上传glb
|
|
|
- uploadToOssUtil.upload(glbPath, String.format(UploadFilePath.USER_EDIT_PATH, num) + sid + ".glb");
|
|
|
+ if(!FileUtil.exist(glbPath)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传glb
|
|
|
+ uploadToOssUtil.upload(glbPath, String.format(UploadFilePath.USER_EDIT_PATH, num) + sid + ".glb");
|
|
|
|
|
|
- return ResultData.ok(sid + ".glb");
|
|
|
+ return ResultData.ok(sid + ".glb");
|
|
|
+ }finally {
|
|
|
+ FileUtil.del(path);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|