|
@@ -1,19 +1,17 @@
|
|
package com.ozs.common.utils;
|
|
package com.ozs.common.utils;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
|
+
|
|
|
|
+import com.ozs.common.core.domain.AjaxResult;
|
|
import io.minio.MinioClient;
|
|
import io.minio.MinioClient;
|
|
import io.minio.PutObjectArgs;
|
|
import io.minio.PutObjectArgs;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.apache.poi.ss.usermodel.DateUtil;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
-
|
|
|
|
-import javax.annotation.PostConstruct;
|
|
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -21,16 +19,20 @@ import java.util.Map;
|
|
@Slf4j
|
|
@Slf4j
|
|
@Component
|
|
@Component
|
|
public class MinioUtils {
|
|
public class MinioUtils {
|
|
- @Value("${minio.endpoint}")
|
|
|
|
|
|
+
|
|
|
|
+ @Value(value = "${minio.endpoint}")
|
|
private String endpoint;
|
|
private String endpoint;
|
|
- @Value("${minio.accessKey}")
|
|
|
|
|
|
+
|
|
|
|
+ @Value(value = "${minio.accessKey}")
|
|
private String accessKey;
|
|
private String accessKey;
|
|
- @Value("${minio.secretKey}")
|
|
|
|
|
|
+
|
|
|
|
+ @Value(value = "${minio.secretKey}")
|
|
private String secretKey;
|
|
private String secretKey;
|
|
- @Value("${minio.bucketName}")
|
|
|
|
|
|
+
|
|
|
|
+ @Value(value = "${minio.bucketName}")
|
|
private String bucketName;
|
|
private String bucketName;
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传
|
|
* 上传
|
|
@@ -48,6 +50,8 @@ public class MinioUtils {
|
|
//添加自定义/用户元数据
|
|
//添加自定义/用户元数据
|
|
Map<String, String> userMetadata = new HashMap<>(10);
|
|
Map<String, String> userMetadata = new HashMap<>(10);
|
|
userMetadata.put("My-Project", "Project One");
|
|
userMetadata.put("My-Project", "Project One");
|
|
|
|
+
|
|
|
|
+
|
|
MinioClient minioClient =
|
|
MinioClient minioClient =
|
|
MinioClient.builder()
|
|
MinioClient.builder()
|
|
.endpoint(endpoint)
|
|
.endpoint(endpoint)
|
|
@@ -62,5 +66,6 @@ public class MinioUtils {
|
|
.userMetadata(userMetadata)
|
|
.userMetadata(userMetadata)
|
|
.build());
|
|
.build());
|
|
imgInputStream.close();
|
|
imgInputStream.close();
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|