diff --git a/src/main/java/cn/wisenergy/chnmuseum/party/web/controller/AssetController.java b/src/main/java/cn/wisenergy/chnmuseum/party/web/controller/AssetController.java index 71c9af34260a48c7b96bd2c87098e141882007d5..e4e459f8dc6312e3e2861ad113ab2f873f318e67 100644 --- a/src/main/java/cn/wisenergy/chnmuseum/party/web/controller/AssetController.java +++ b/src/main/java/cn/wisenergy/chnmuseum/party/web/controller/AssetController.java @@ -104,7 +104,7 @@ public class AssetController extends BaseController { return getResult(asset); } - @ApiOperation(value = "视频文件汇出", notes = "视频文件汇出") + @ApiOperation(value = "视频文件汇出POST", notes = "视频文件汇出POST") @ApiImplicitParams({ @ApiImplicitParam(name = "idList", value = "è§†é¢‘æ–‡ä»¶æ ‡è¯†ID集åˆ", dataType = "String", paramType = "query") }) @@ -136,5 +136,37 @@ public class AssetController extends BaseController { ZipUtil.zip(outputStream, paths, ins); } + @ApiOperation(value = "视频文件汇出GET", notes = "视频文件汇出GET") + @ApiImplicitParams({ + @ApiImplicitParam(name = "idList", value = "è§†é¢‘æ–‡ä»¶æ ‡è¯†ID集åˆ", dataType = "String", paramType = "query") + }) + @GetMapping("/download") + @RequiresAuthentication + @MethodLog(operModule = OperModule.VIDEOREMIT, operType = OperType.VIDEO_EXPORT) + public void downloadByGet(@RequestParam("idList") List<String> idList, HttpServletResponse response) throws IOException { + response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); + response.addHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncoder.encode("file.zip", "UTF-8")); + + final Map<String, InputStream> map = new LinkedHashMap<>(idList.size() + 1); + final List<Asset> assetList = assetService.listByIds(idList); + final String cipher = RandomUtil.randomString(BASE_STRING, 16); + for (final Asset asset : assetList) { + final String fileUrl = asset.getFileUrl(); + ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); + FastDFSUtils.downloadFile(fileUrl, byteOutputStream); + final Set<MetaData> fileMetaData = FastDFSUtils.getFileMetaData(fileUrl); + //String fileName = fileMetaData.stream().filter(x -> "MD5".equals(x.getName())).map(MetaData::getValue).findFirst().get() + ".chnmuseum"; + map.put(asset.getFileName(), new ByteArrayInputStream(byteOutputStream.toByteArray())); + } + final TUser user = getcurUser(); + final TBoxOperation tBoxOperation = this.tBoxOperationService.getOne(Wrappers.<TBoxOperation>lambdaQuery().eq(TBoxOperation::getOrganId, user.getOrgId())); + map.put("cipher.txt", IoUtil.toStream(RSAUtils.encrypt(cipher, tBoxOperation.getPublicKey()), StandardCharsets.UTF_8)); + + ServletOutputStream outputStream = response.getOutputStream(); + String[] paths = map.keySet().toArray(new String[0]); + InputStream[] ins = map.values().toArray(new InputStream[0]); + ZipUtil.zip(outputStream, paths, ins); + } + }