| | |
| | | import org.springblade.mdm.flow.entity.FlowProgramFile; |
| | | import org.springblade.mdm.flow.mapper.FlowProgramFileMapper; |
| | | import org.springblade.mdm.flow.vo.ProgramUploadVO; |
| | | import org.springblade.mdm.utils.FileContentUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | |
| | | FlowProgramProperties progProps= flowCommonService.getProgramProperties(uploadVO.getProcessInstanceId()); |
| | | MultipartFile file = uploadVO.getFile(); |
| | | if(file.getSize() == 0){ |
| | | throw new ServiceException("程序文件不可为空文件"); |
| | | } |
| | | checkFilename(file.getOriginalFilename(),progProps); |
| | | |
| | | String programName = getProgramName(progProps); |
| | |
| | | |
| | | /** |
| | | * 获取文件内容 |
| | | * @param id |
| | | * @return |
| | | * @param id 文件id |
| | | * @return 文件内容文本 |
| | | */ |
| | | public String getFileContent(Long id) { |
| | | String result =""; |
| | | |
| | | FlowProgramFile programFile = this.getById(id); |
| | | //if(prog.getIsTextFile()!=null && programFile.getIsTextFile()){ |
| | | /* |
| | | String fileName = programFile.getOssName(); |
| | | try (InputStream inputStream = ossTemplate.statFileStream(fileName)) { |
| | | result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | //}else{ |
| | | // result = "非文本格式文件"; |
| | | //} |
| | | */ |
| | | |
| | | String fileName = programFile.getOssName(); |
| | | try (InputStream inputStream = ossTemplate.statFileStream(fileName)) { |
| | | result = FileContentUtil.getContentFromStream(inputStream); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |