|
@@ -514,36 +514,54 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResultData downloadPanorama(String num) throws Exception {
|
|
|
+ public ResultData downloadPanorama(FileParamVO param) throws Exception {
|
|
|
+
|
|
|
+ String num = param.getNum();
|
|
|
+ String fileName = param.getFileName();
|
|
|
|
|
|
String cachePath = String.format(ConstantFilePath.SCENE_CACHE, num);
|
|
|
String imgCachePath = String.format(UploadFilePath.IMG_CACHES_PATH, num);
|
|
|
String localImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
|
|
|
- List<String> keyList = uploadToOssUtil.listKeys(imgCachePath);
|
|
|
+
|
|
|
+ String cacheFormat = "downloads/scene/%s/caches/";
|
|
|
+ String cacheImageFormat = "downloads/scene/%s/caches/images/";
|
|
|
+ //如果入参文件名不为空,则是单个文件下载,不需要打包
|
|
|
+ if(StrUtil.isNotEmpty(fileName)){
|
|
|
+ //先下载到本地
|
|
|
+ if (!StorageType.LOCAL.code().equals(this.type)) {// TODO: 2022/2/15 这里有可能有问题,可能还需要考虑本地部署的情况
|
|
|
+ String filePath = imgCachePath + fileName;
|
|
|
+ String imageUrl = ossUrlPrefix + filePath + "?t=" + System.currentTimeMillis();
|
|
|
+ FileUtils.downLoadFromUrl(imageUrl, fileName, localImagesPath);
|
|
|
+ }
|
|
|
+ //上传
|
|
|
+ uploadToOssUtil.upload(localImagesPath + fileName, String.format(cacheImageFormat, num) + fileName);
|
|
|
+ String url = ossUrlPrefix + String.format(cacheImageFormat, num) + fileName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("fileUrl", url + "?t=" + System.currentTimeMillis());
|
|
|
+ map.put("fileName", fileName);
|
|
|
+ return ResultData.ok(map);
|
|
|
+ }
|
|
|
|
|
|
//先下载到本地
|
|
|
+ List<String> keyList = uploadToOssUtil.listKeys(imgCachePath);
|
|
|
if (!StorageType.LOCAL.code().equals(this.type)) {// TODO: 2022/2/15 这里有可能有问题,可能还需要考虑本地部署的情况
|
|
|
keyList.stream().forEach(key->{
|
|
|
- String fileName = key.substring(key.lastIndexOf("/") + 1);
|
|
|
- String imageUrl = ossUrlPrefix + imgCachePath + fileName + "?t=" + System.currentTimeMillis();
|
|
|
- FileUtils.downLoadFromUrl(imageUrl, fileName, localImagesPath);
|
|
|
+ String file = key.substring(key.lastIndexOf("/") + 1);
|
|
|
+ String imageUrl = ossUrlPrefix + imgCachePath + file + "?t=" + System.currentTimeMillis();
|
|
|
+ FileUtils.downLoadFromUrl(imageUrl, file, localImagesPath);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
//打包
|
|
|
String zipName = num + "_images.zip";
|
|
|
String zipPath = cachePath + zipName;
|
|
|
FileUtil.zip(localImagesPath, zipPath, false);
|
|
|
-
|
|
|
//上传压缩包
|
|
|
- uploadToOssUtil.upload(zipPath, "downloads/caches/" + zipName);
|
|
|
-
|
|
|
- String url = ossUrlPrefix + "downloads/caches/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
+ uploadToOssUtil.upload(zipPath, String.format(cacheFormat, num) + zipName);
|
|
|
+ String url = ossUrlPrefix + String.format(cacheFormat, num) + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("fileUrl", url + "?t=" + System.currentTimeMillis());
|
|
|
- map.put("fileName", url.substring(url.lastIndexOf("/") + 1));
|
|
|
-
|
|
|
+ map.put("fileName", zipName);
|
|
|
return ResultData.ok(map);
|
|
|
}
|
|
|
|