fix: 修改minio操作类,解决作为依赖使用时出现的启动异常;发布测试版本mvn2.0.1.2023102502.Alpha

main
hong.yang 1 year ago
parent 5999aae0f1
commit 12b2799f67

@ -6,7 +6,7 @@
<parent>
<groupId>com.gccloud</groupId>
<artifactId>dataroom</artifactId>
<version>2.0.1.2023102401.Alpha</version>
<version>2.0.1.2023102502.Alpha</version>
</parent>
<artifactId>dataroom-core</artifactId>

@ -1,26 +1,13 @@
package com.gccloud.dataroom.core.utils;
import com.gccloud.dataroom.core.config.bean.DataRoomMinioConfig;
import io.minio.BucketExistsArgs;
import io.minio.GetObjectArgs;
import io.minio.GetPresignedObjectUrlArgs;
import io.minio.MakeBucketArgs;
import io.minio.MinioClient;
import io.minio.RemoveObjectArgs;
import io.minio.errors.ErrorResponseException;
import io.minio.errors.InsufficientDataException;
import io.minio.errors.InternalException;
import io.minio.errors.InvalidResponseException;
import io.minio.errors.ServerException;
import io.minio.errors.XmlParserException;
import io.minio.*;
import io.minio.http.Method;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import java.io.IOException;
import javax.annotation.Resource;
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
/**
* Minio
@ -28,11 +15,12 @@ import java.security.NoSuchAlgorithmException;
* @author Acechengui
*/
@Component
@ConditionalOnProperty(prefix = "gc.starter.file", name = "type", havingValue = "minio")
public class MinioFileInterface {
@Autowired
@Resource
private DataRoomMinioConfig minioConfig;
private MinioClient init() throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
private MinioClient init() throws Exception {
MinioClient build = MinioClient.builder().endpoint(minioConfig.getUrl()).credentials(minioConfig.getAccessKey(), minioConfig.getSecretKey()).build();
//判断bucket是否存在没有就创建
boolean found =build.bucketExists(BucketExistsArgs.builder().bucket(minioConfig.getBucketName()).build());
@ -46,7 +34,7 @@ public class MinioFileInterface {
*
* @param objectName
*/
public void deleteObject(String objectName) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
public void deleteObject(String objectName) throws Exception {
MinioClient minioClient = init();
//删除文件时,如果对应文件夹下的文件已删除完,文件夹会自动删除
minioClient.removeObject(RemoveObjectArgs.builder()
@ -60,7 +48,7 @@ public class MinioFileInterface {
*
* @param objectName
*/
public InputStream download(String objectName) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
public InputStream download(String objectName) throws Exception {
MinioClient minioClient = init();
// 获取文件输入流
return minioClient.getObject(
@ -79,7 +67,7 @@ public class MinioFileInterface {
* @param expires 7
* @return url
*/
public String presignedGetObject(String bucketName, String objectName, Integer expires) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
public String presignedGetObject(String bucketName, String objectName, Integer expires) throws Exception {
String url = "";
if (expires == null){
expires = 604800;

@ -6,7 +6,7 @@
<parent>
<groupId>com.gccloud</groupId>
<artifactId>dataroom</artifactId>
<version>2.0.1.2023102401.Alpha</version>
<version>2.0.1.2023102502.Alpha</version>
</parent>
<artifactId>dataroom-server</artifactId>

@ -5,7 +5,7 @@
<groupId>com.gccloud</groupId>
<artifactId>dataroom</artifactId>
<version>2.0.1.2023102401.Alpha</version>
<version>2.0.1.2023102502.Alpha</version>
<packaging>pom</packaging>
<name>dataroom</name>

Loading…
Cancel
Save