| | |
| | | if(StringUtils.isBlank(param.getUrl())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | InputStream inputStream = HttpsUtil.connectionInputsteam(param.getUrl(),"GET","",null); |
| | | InputStream inputStream = HttpsUtil.connectionInputsteam(param.getUrl(),"GET",null,null); |
| | | if(inputStream == null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"文件下载失败,请检查文件路径是否合法!"); |
| | | } |
| | |
| | | param.setFileName(System.currentTimeMillis()+"."+nfix); |
| | | } |
| | | } |
| | | |
| | | String encodeFileName = URLEncoder.encode(param.getFileName(), Charset.forName("UTF-8").toString()); |
| | | response.setHeader("Content-Disposition","attachment;filename=" + encodeFileName); |
| | | response.setContentType("application/octet-stream"); |
| | | response.setHeader("eva-opera-type", "download"); |
| | | response.setHeader("eva-download-filename", encodeFileName); |
| | | ServletOutputStream os = response.getOutputStream(); |
| | | |
| | | OutputStream os = new BufferedOutputStream(response.getOutputStream()); |
| | | byte[] buffer = new byte[4096]; |
| | | int bytesRead; |
| | | while ((bytesRead = inputStream.read(buffer)) != -1) { |