| | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: <br> |
| | | * @Project: <br> |
| | | * @Description: AbstractIFileService 抽取类<br> |
| | | * @Project: 根据kidgrow.file-server.type 实例化具体对象<br> |
| | | * @CreateDate: Created in 2020/2/18 11:24 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | |
| | | * @param fileInfo |
| | | */ |
| | | protected abstract void uploadFile(MultipartFile file, FileInfo fileInfo) throws Exception; |
| | | protected abstract void fileUpLoadOss(FileInfo fileInfo,String newFilePath, InputStream fileStream); |
| | | protected abstract void fileUpLoadOss(FileInfo fileInfo,String newFilePath, InputStream fileStream,String fileFolder); |
| | | protected abstract String FilePath(String imgType,String folderByDate,String hospitalId,String departmentId); |
| | | protected abstract OSSObject down(String url); |
| | | |
| | |
| | | newfileInfo.setImgType(imgType); |
| | | newfileInfo.setCreateTime(new Date()); |
| | | //文件上传到oss |
| | | this.fileUpLoadOss(newfileInfo,filefloder+newFileName,inputStream); |
| | | this.fileUpLoadOss(newfileInfo,filefloder+newFileName,inputStream,filefloder); |
| | | inputStream.close(); |
| | | // //删除暂存文件 |
| | | // MultipartFileUtils.delteTempFile(thuFile); |
| | |
| | | newfileInfo.setCreateTime(new Date()); |
| | | String folderByDate =DateUtil.formatDate(new Date()); |
| | | String filePath = FilePath(imgType, folderByDate, hospitalId, departmentId); |
| | | this.fileUpLoadOss(newfileInfo,filePath+newFileName,input); |
| | | this.fileUpLoadOss(newfileInfo,filePath+newFileName,input,filePath); |
| | | input.close(); |
| | | baseMapper.insert(newfileInfo); |
| | | return newfileInfo; |
| | |
| | | newfileInfo.setSource("aliyun"); |
| | | newfileInfo.setImgType(houzhui); |
| | | newfileInfo.setCreateTime(new Date()); |
| | | this.fileUpLoadOss(newfileInfo,"pdf/"+newFileName,inputStream); |
| | | this.fileUpLoadOss(newfileInfo,"pdf/"+newFileName,inputStream,"pdf/"); |
| | | baseMapper.insert(newfileInfo); |
| | | inputStream.close(); |
| | | return newfileInfo; |
| | |
| | | public FileInfo feignUploadHosIdAndDepId(MultipartFile file, String imgType, String hospitalId, String departmentId) throws Exception { |
| | | List<String> lassStr= Arrays.asList("png","bmp","dib","gif","jfif","jpe","jpeg","jpg","tif","tiff","ico"); |
| | | String suffix=file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); |
| | | if(!lassStr.contains(suffix)){ |
| | | if(!lassStr.contains(suffix.toLowerCase())){ |
| | | return null; |
| | | } |
| | | String name = file.getOriginalFilename(); |
| | |
| | | String folderByDate =DateUtil.formatDate(new Date()); |
| | | String filePath = FilePath(imgType, folderByDate, hospitalId, departmentId); |
| | | InputStream inputStream = file.getInputStream(); |
| | | this.fileUpLoadOss(newfileInfo,filePath+newFileName,inputStream); |
| | | this.fileUpLoadOss(newfileInfo,filePath+newFileName,inputStream,filePath); |
| | | inputStream.close(); |
| | | baseMapper.insert(newfileInfo); |
| | | return newfileInfo; |