| | |
| | | public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> implements FileInfoService { |
| | | |
| | | private final SystemConfigProperties systemConfigProperties; |
| | | private final FileInfoMapper fileInfoMapper; |
| | | @Override |
| | | public String downloadPathFile(String downloadPath, HttpServletRequest request, HttpServletResponse response) { |
| | | //设置文件路径 |
| | |
| | | System.out.println("文件读取异常,"+e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void getFileById(Long fileId, HttpServletResponse response) { |
| | | try { |
| | | FileInfo fileInfo = fileInfoMapper.selectById(fileId); |
| | | InputStream input = new FileInputStream(new File(fileInfo.getFileBaseDir()+fileInfo.getFileName()+fileInfo.getFileLast())); |
| | | response.setContentType(MediaType.IMAGE_PNG_VALUE); |
| | | IoUtil.copy(input, response.getOutputStream()); |
| | | }catch (Exception e){ |
| | | System.out.println("文件读取异常,"+e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | } |