|
|
|
@ -3,6 +3,8 @@ package com.example.demo.controller;
|
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.SneakyThrows; |
|
|
|
|
import org.springblade.core.boot.ctrl.BladeController; |
|
|
|
|
import org.springblade.core.boot.file.LocalFile; |
|
|
|
|
import org.springblade.core.oss.minio.MinioTemplate; |
|
|
|
|
import org.springblade.core.oss.model.BladeFile; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
@ -21,7 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@AllArgsConstructor |
|
|
|
|
@RequestMapping("/notice/upload") |
|
|
|
|
@Api(value = "对象存储接口", tags = "oss上传测试") |
|
|
|
|
public class UploadController { |
|
|
|
|
public class UploadController extends BladeController { |
|
|
|
|
|
|
|
|
|
private final MinioTemplate minioTemplate; |
|
|
|
|
|
|
|
|
@ -29,7 +31,7 @@ public class UploadController {
|
|
|
|
|
* minio上传demo |
|
|
|
|
* |
|
|
|
|
* @param file 上传文件 |
|
|
|
|
* @return String |
|
|
|
|
* @return BladeFile |
|
|
|
|
*/ |
|
|
|
|
@SneakyThrows |
|
|
|
|
@PostMapping("put-object") |
|
|
|
@ -38,4 +40,18 @@ public class UploadController {
|
|
|
|
|
return R.data(bladeFile); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 上传本地文件 |
|
|
|
|
* |
|
|
|
|
* @param file 上传文件 |
|
|
|
|
* @return LocalFile |
|
|
|
|
*/ |
|
|
|
|
@SneakyThrows |
|
|
|
|
@PostMapping("put-local-object") |
|
|
|
|
public R<LocalFile> putLocalObject(@RequestParam MultipartFile file) { |
|
|
|
|
LocalFile localFile = getFile(file); |
|
|
|
|
localFile.transfer(); |
|
|
|
|
return R.data(localFile); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|