| | |
| | | import org.springblade.core.tool.utils.Func; |
| | | import com.vci.ubcs.resource.builder.oss.OssBuilder; |
| | | import com.vci.ubcs.resource.service.IAttachService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * 对象存储端点 |
| | | * |
| | | * 这个类不使用,统一用fileController |
| | | * |
| | | * @author Chill |
| | | */ |
| | |
| | | @AllArgsConstructor |
| | | @RequestMapping("/oss/endpoint") |
| | | @Api(value = "对象存储端点", tags = "对象存储端点") |
| | | @Deprecated |
| | | public class OssEndpoint { |
| | | |
| | | /** |
| | |
| | | * 附件表服务 |
| | | */ |
| | | private final IAttachService attachService; |
| | | |
| | | |
| | | /** |
| | | * 创建存储桶 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 创建存储桶 |
| | | * 删除存储桶 |
| | | * |
| | | * @param bucketName 存储桶名称 |
| | | * @return R |
| | |
| | | public R<OssFile> statFile(@RequestParam String fileName) { |
| | | return R.data(ossBuilder.template().statFile(fileName)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取文件相对路径 |
| | |
| | | return R.data(bladeFile); |
| | | } |
| | | |
| | | /** |
| | | * 上传文件并保存至附件表 |
| | | * |
| | | * @param file 文件 |
| | | * @return ObjectStat |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-attach") |
| | | public R<BladeFile> putFileAttach(@RequestParam MultipartFile file) { |
| | | String fileName = file.getOriginalFilename(); |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile); |
| | | bladeFile.setAttachId(attachId); |
| | | return R.data(bladeFile); |
| | | } |
| | | // /** |
| | | // * 上传文件并保存至附件表 |
| | | // * |
| | | // * @param file 文件 |
| | | // * @return ObjectStat |
| | | // */ |
| | | // @SneakyThrows |
| | | // @PostMapping("/put-file-attach") |
| | | // public R<BladeFile> putFileAttach(@RequestParam MultipartFile file) { |
| | | // String fileName = file.getOriginalFilename(); |
| | | // BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | // Long attachId = buildAttach(fileName, file.getSize(), bladeFile); |
| | | // bladeFile.setAttachId(attachId); |
| | | // return R.data(bladeFile); |
| | | // } |
| | | |
| | | /** |
| | | * 上传文件并保存至附件表 |
| | | * |
| | | * @param fileName 存储桶对象名称 |
| | | * @param file 文件 |
| | | * @return ObjectStat |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-attach-by-name") |
| | | public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file) { |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile); |
| | | bladeFile.setAttachId(attachId); |
| | | return R.data(bladeFile); |
| | | } |
| | | // /** |
| | | // * 上传文件并保存至附件表 |
| | | // * |
| | | // * @param fileName 存储桶对象名称 |
| | | // * @param file 文件 |
| | | // * @return ObjectStat |
| | | // */ |
| | | // @SneakyThrows |
| | | // @PostMapping("/put-file-attach-by-name") |
| | | // public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file) { |
| | | // BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | // Long attachId = buildAttach(fileName, file.getSize(), bladeFile); |
| | | // bladeFile.setAttachId(attachId); |
| | | // return R.data(bladeFile); |
| | | // } |
| | | |
| | | /** |
| | | * 构建附件表 |