feat: oss develop
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.landaiqing.oss.config;
|
||||
|
||||
import io.minio.MinioClient;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Classname MinioConfig
|
||||
* @BelongsProject: jc-club
|
||||
* @BelongsPackage: com.landaiqing.oss.config
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-17 15:44
|
||||
* @Description: Minio配置管理
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class MinioConfig {
|
||||
/**
|
||||
* minioUrl
|
||||
*/
|
||||
@Value("${minio.url}")
|
||||
private String url;
|
||||
/**
|
||||
* minio账户
|
||||
*/
|
||||
@Value("${minio.accessKey}")
|
||||
private String accessKey;
|
||||
/**
|
||||
* minio密码
|
||||
*/
|
||||
@Value("${minio.secretKey}")
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* 构造minioClient
|
||||
*/
|
||||
@Bean
|
||||
public MinioClient getMinioClient(){
|
||||
return MinioClient.builder().endpoint(url).credentials(accessKey,secretKey ).build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.landaiqing.oss.config;
|
||||
|
||||
import com.landaiqing.oss.adapter.StorageAdapter;
|
||||
import com.landaiqing.oss.adapter.AliStorageAdapter;
|
||||
import com.landaiqing.oss.adapter.MinioStorageAdapter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Classname StorageConfig
|
||||
* @BelongsProject: jc-club
|
||||
* @BelongsPackage: com.landaiqing.oss.config
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-17 16:52
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@RefreshScope
|
||||
public class StorageConfig {
|
||||
@Value("${storage.service.type}")
|
||||
private String storageType;
|
||||
|
||||
|
||||
@Bean
|
||||
@RefreshScope
|
||||
public StorageAdapter storageService(){
|
||||
if ("minio".equals(storageType)) {
|
||||
return new MinioStorageAdapter();
|
||||
} else if ("aliyun".equals(storageType)) {
|
||||
return new AliStorageAdapter();
|
||||
} else {
|
||||
throw new IllegalArgumentException("未找到对应的文件处理");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user