|
@@ -6,6 +6,7 @@ import api.common.util.FileUtil;
|
|
import com.css.simulation.resource.common.util.MinioUtil;
|
|
import com.css.simulation.resource.common.util.MinioUtil;
|
|
import io.minio.MinioClient;
|
|
import io.minio.MinioClient;
|
|
import io.minio.errors.*;
|
|
import io.minio.errors.*;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -25,6 +26,9 @@ public class MinioController {
|
|
@Resource
|
|
@Resource
|
|
private MinioClient minioClient;
|
|
private MinioClient minioClient;
|
|
|
|
|
|
|
|
+ @Value("${oauth.bucket-name}")
|
|
|
|
+ private String bucketName;
|
|
|
|
+
|
|
|
|
|
|
@PostMapping("/hello")
|
|
@PostMapping("/hello")
|
|
public String hello() {
|
|
public String hello() {
|
|
@@ -34,7 +38,6 @@ public class MinioController {
|
|
@PostMapping(value="/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
@PostMapping(value="/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
public ResponseBodyVO<String> upload(
|
|
public ResponseBodyVO<String> upload(
|
|
@RequestPart("file") MultipartFile file,
|
|
@RequestPart("file") MultipartFile file,
|
|
- @RequestParam("bucketName") String bucketName,
|
|
|
|
@RequestParam("objectName") String objectName// "/xx/xxx/x/xx"
|
|
@RequestParam("objectName") String objectName// "/xx/xxx/x/xx"
|
|
) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
|
) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
|
MinioUtil.uploadFromMultipartFile(
|
|
MinioUtil.uploadFromMultipartFile(
|
|
@@ -53,7 +56,7 @@ public class MinioController {
|
|
) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
|
) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
|
InputStream inputStream = MinioUtil.downloadToStream(
|
|
InputStream inputStream = MinioUtil.downloadToStream(
|
|
minioClient,
|
|
minioClient,
|
|
- minioParameter.getBucketName(),
|
|
|
|
|
|
+ bucketName,
|
|
minioParameter.getObjectName()
|
|
minioParameter.getObjectName()
|
|
);
|
|
);
|
|
String fileName = FileUtil.getFileName(minioParameter.getObjectName());
|
|
String fileName = FileUtil.getFileName(minioParameter.getObjectName());
|