@ApiOperation(value = "下载资源", notes = "根据资源id下载http://127.0.0.1:8080/app/public/download/Asset?fileKey=null66eb4a32fee531688c0b90c79fc7e7c9")
@GetMapping("/download/Asset")
public void downloadAsset(HttpServletResponse request, String fileKey) {
List<AppAsset> list = appAssetService.selectAppAssetList(AppAsset.fromFileKey(fileKey));
if (list != null && list.size() == 1) {
AppAsset res = list.get(0);
logger.info(res.toString());
request.setCharacterEncoding("UTF-8");
request.setContentType("text/html");
try {
String s1 = res.getFilePath().substring(0, res.getFilePath().lastIndexOf("/") + 1);
String s = res.getFilePath().substring(res.getFilePath().lastIndexOf("/") + 1);
request.sendRedirect(s1 + URLEncoder.encode(s, "UTF-8"));
appAssetService.addDownloadTimes(res.getId());
} catch (IOException e) {
e.printStackTrace();
}
}
}
2