| | |
| | | public static void downloadFile(HttpServletResponse response, FileObjectBO fileObjectBO,boolean closeInputStream) throws IOException { |
| | | MediaType mediaType = MediaTypeFactory.getMediaType(fileObjectBO.getBucketName() + "." + fileObjectBO.getFileExtension()).orElse(MediaType.APPLICATION_OCTET_STREAM); |
| | | // 设置强制下载不打开 |
| | | response.setContentType(mediaType.toString()); |
| | | response.setContentType(mediaType.toString()+";application/force-download;charset=UTF-8"); |
| | | try{ |
| | | String fileName = URLEncoder.encode(fileObjectBO.getName() + "." + fileObjectBO.getFileExtension(), "UTF8"); |
| | | response.addHeader("Content-Disposition", "attachment; filename="+ fileName+ ";filename*=utf-8''" + fileName); |
| | | response.addHeader("Content-Disposition", "attachment;filename="+ fileName+ ";filename*=utf-8''"); |
| | | }catch(Exception e){ |
| | | if(log.isErrorEnabled()){ |
| | | log.error("设置文件的名称到响应流的时候出错",e); |