| | |
| | | @PostMapping("/put-file-attach-by-name") |
| | | @ApiOperation(value = "上传文件并保存至附件表", notes = "上传文件并保存至附件表-存储桶对象名称") |
| | | public R<BladeFile> putFileAttach(@RequestParam String fileName, |
| | | @RequestParam Integer resultType, |
| | | @RequestParam String resultType, |
| | | @RequestParam MultipartFile file) { |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | Long attachId = buildAttach(fileName, resultType, file.getSize(), bladeFile); |
| | |
| | | private BladeFile getBladeFile(@RequestParam MultipartFile file) throws IOException { |
| | | String fileName = file.getOriginalFilename(); |
| | | BladeFile bladeFile = ossBuilder.template("estack").putFile(fileName, file.getInputStream()); |
| | | Long attachId = buildAttach(fileName, null, file.getSize(), bladeFile); |
| | | Long attachId = buildAttach(fileName, "", file.getSize(), bladeFile); |
| | | bladeFile.setAttachId(attachId); |
| | | return bladeFile; |
| | | } |
| | |
| | | * @param bladeFile 对象存储文件 |
| | | * @return attachId |
| | | */ |
| | | private Long buildAttach(String fileName, Integer resultType, Long fileSize, BladeFile bladeFile) { |
| | | private Long buildAttach(String fileName, String resultType, Long fileSize, BladeFile bladeFile) { |
| | | String fileExtension = FileUtil.getFileExtension(fileName); |
| | | Attach attach = new Attach(); |
| | | attach.setDomainUrl(bladeFile.getDomain()); |