| | |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-attach-by-name") |
| | | public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file) { |
| | | public R<BladeFile> putFileAttach(@RequestParam(required = false) String fileName, @RequestParam MultipartFile file) { |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile); |
| | | bladeFile.setAttachId(attachId); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 自定义前缀上传文件 |
| | | * |
| | | * @param file 文件 |
| | | * @param prefixPath 文件 |
| | | * @return ObjectStat |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-by-prefix-path") |
| | | public R<BladeFile> putFileByPrefixPath(@RequestParam MultipartFile file,@RequestParam(required = false) String prefixPath) { |
| | | BladeFile bladeFile = ossBuilder.templateByPrefixPath(prefixPath).putFile(file.getOriginalFilename(), file.getInputStream()); |
| | | // 修改link |
| | | changeLink(bladeFile); |
| | | return R.data(bladeFile); |
| | | } |
| | | |
| | | /** |
| | | * 自定义前缀上传文件并保存至附件表 |
| | | * |
| | | * @param file 文件 |
| | | * @param prefixPath 文件 |
| | | * @return ObjectStat |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-attach-by-prefix-path") |
| | | public R<BladeFile> putFileAttachByPrefixPath(@RequestParam MultipartFile file,@RequestParam(required = false) String prefixPath) { |
| | | String fileName = file.getOriginalFilename(); |
| | | BladeFile bladeFile = ossBuilder.templateByPrefixPath(prefixPath).putFile(file.getOriginalFilename(), file.getInputStream()); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile); |
| | | bladeFile.setAttachId(attachId); |
| | | // 修改link |
| | | changeLink(bladeFile); |
| | | return R.data(bladeFile); |
| | | } |
| | | |
| | | /** |
| | | * 构建附件表 |
| | | * |
| | | * @param fileName 文件名 |