java spring接口中转发文件
@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 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
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
