ruoyi-file 动态实现 bean 注入
This commit is contained in:
parent
4ca50fa0c6
commit
cfb590a039
|
|
@ -17,7 +17,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = AliyunOssConfig.PREFIX)
|
@ConfigurationProperties(prefix = AliyunOssConfig.PREFIX)
|
||||||
public class AliyunOssConfig {
|
public class AliyunOssConfig {
|
||||||
public static final String PREFIX = "aliyun-oss";
|
public static final String PREFIX = "file.aliyun-oss";
|
||||||
/**
|
/**
|
||||||
* aliyun oss相关配置
|
* aliyun oss相关配置
|
||||||
* ACCESS_KEY_SECRET
|
* ACCESS_KEY_SECRET
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
prefix = CephConfig.PREFIX
|
prefix = CephConfig.PREFIX
|
||||||
)
|
)
|
||||||
public class CephConfig {
|
public class CephConfig {
|
||||||
public static final String PREFIX = "ceph";
|
public static final String PREFIX = "file.ceph";
|
||||||
/**
|
/**
|
||||||
* s3 提供的 accessKey secretKey
|
* s3 提供的 accessKey secretKey
|
||||||
* 示例:
|
* 示例:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ package com.ruoyi.file.config;
|
||||||
|
|
||||||
import com.github.tobato.fastdfs.FdfsClientConstants;
|
import com.github.tobato.fastdfs.FdfsClientConstants;
|
||||||
import com.github.tobato.fastdfs.domain.conn.PooledConnectionFactory;
|
import com.github.tobato.fastdfs.domain.conn.PooledConnectionFactory;
|
||||||
|
import com.github.tobato.fastdfs.domain.conn.TrackerConnectionManager;
|
||||||
import com.ruoyi.file.service.FastDfsSysFileServiceImpl;
|
import com.ruoyi.file.service.FastDfsSysFileServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -24,7 +26,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
public class FastDfsConfig {
|
public class FastDfsConfig {
|
||||||
/**
|
/**
|
||||||
* 文件对外访问域名or ip
|
* 文件对外访问域名or ip
|
||||||
* FastDFS配置 其他参数见:{@link PooledConnectionFactory}
|
* FastDFS配置 其他参数见:{@link PooledConnectionFactory} {@link TrackerConnectionManager}
|
||||||
* //@Value("${fdfs.domain}")
|
* //@Value("${fdfs.domain}")
|
||||||
*/
|
*/
|
||||||
private String domain;
|
private String domain;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
prefix = FtpConfig.PREFIX
|
prefix = FtpConfig.PREFIX
|
||||||
)
|
)
|
||||||
public class FtpConfig {
|
public class FtpConfig {
|
||||||
public static final String PREFIX = "ftp";
|
public static final String PREFIX = "file.ftp";
|
||||||
/**
|
/**
|
||||||
* ftp访问地址
|
* ftp访问地址
|
||||||
* eg1: www.ourslook.com
|
* eg1: www.ourslook.com
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = MinioConfig.PREFIX)
|
@ConfigurationProperties(prefix = MinioConfig.PREFIX)
|
||||||
public class MinioConfig {
|
public class MinioConfig {
|
||||||
public static final String PREFIX = "minio";
|
public static final String PREFIX = "file.minio";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MinioClient getMinioClient() {
|
public MinioClient getMinioClient() {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = QiniuKodoConfig.PREFIX)
|
@ConfigurationProperties(prefix = QiniuKodoConfig.PREFIX)
|
||||||
public class QiniuKodoConfig {
|
public class QiniuKodoConfig {
|
||||||
public static final String PREFIX = "qiniu";
|
public static final String PREFIX = "file.qiniu";
|
||||||
/**
|
/**
|
||||||
* AccessKey 简称ak
|
* AccessKey 简称ak
|
||||||
* 申请地址=>登录七牛云:https://portal.qiniu.com/user/key
|
* 申请地址=>登录七牛云:https://portal.qiniu.com/user/key
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
@ConfigurationProperties(prefix = ResourcesConfig.PREFIX)
|
@ConfigurationProperties(prefix = ResourcesConfig.PREFIX)
|
||||||
public class ResourcesConfig implements WebMvcConfigurer
|
public class ResourcesConfig implements WebMvcConfigurer
|
||||||
{
|
{
|
||||||
public static final String PREFIX = "file";
|
public static final String PREFIX = "file.local-file";
|
||||||
/**
|
/**
|
||||||
* 文件对外访问地址,一般就是应用 或者 nginx对外地址
|
* 文件对外访问地址,一般就是应用 或者 nginx对外地址
|
||||||
* eg: http://127.0.0.1:9300
|
* eg: http://127.0.0.1:9300
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = TencentCosConfig.PREFIX)
|
@ConfigurationProperties(prefix = TencentCosConfig.PREFIX)
|
||||||
public class TencentCosConfig {
|
public class TencentCosConfig {
|
||||||
public static final String PREFIX = "tencent-cos";
|
public static final String PREFIX = "file.tencent-cos";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public COSClient getCosClient() {
|
public COSClient getCosClient() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
package com.ruoyi.file.config;
|
||||||
|
|
||||||
|
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||||
|
import com.qcloud.cos.COSClient;
|
||||||
|
import com.ruoyi.file.service.*;
|
||||||
|
import io.minio.MinioClient;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.context.annotation.*;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义webmvc config
|
||||||
|
*
|
||||||
|
* @author yabo
|
||||||
|
* @date 2021-11-18
|
||||||
|
* <p>
|
||||||
|
* private RequestMappingHandlerAdapter requestMappingHandlerAdapter;
|
||||||
|
* ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) requestMappingHandlerAdapter.getWebBindingInitializer();
|
||||||
|
* if (initializer.getConversionService() != null) {
|
||||||
|
* GenericConversionService genericConversionService = (GenericConversionService) initializer.getConversionService();
|
||||||
|
* genericConversionService.addConverter(new CustomConverter());
|
||||||
|
* }
|
||||||
|
* @see ISysFileService
|
||||||
|
* // 具体实现config
|
||||||
|
* @see AliyunOssConfig 阿里云oss
|
||||||
|
* @see CephConfig ceph文件服务
|
||||||
|
* @see FastDfsConfig fastdfs
|
||||||
|
* @see FtpConfig ftp
|
||||||
|
* @see MinioConfig minio
|
||||||
|
* @see QiniuKodoConfig 七牛kodo
|
||||||
|
* @see ResourcesConfig tomcat映射目录
|
||||||
|
* @see TencentCosConfig 腾讯云cos文件服务器
|
||||||
|
*/
|
||||||
|
@RefreshScope
|
||||||
|
@ConfigurationProperties(prefix = WebMvcConfig.PREFIX)
|
||||||
|
@Configuration
|
||||||
|
public class WebMvcConfig implements WebMvcConfigurer, ApplicationContextAware {
|
||||||
|
public static final String PREFIX = "file";
|
||||||
|
/***
|
||||||
|
* 指定文件服务器类型
|
||||||
|
*/
|
||||||
|
protected ISysFileService.DfsTypeEnum fileServerType = ISysFileService.DfsTypeEnum.DEFAULT;
|
||||||
|
|
||||||
|
@Primary
|
||||||
|
@Description("dfs bean.....")
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
@Bean(name = "ISysFileService")
|
||||||
|
public ISysFileService registFileBean(FastFileStorageClient fastFileStorageClient, FastDfsConfig fastDfsConfig,
|
||||||
|
FtpConfig ftpConfig,
|
||||||
|
AliyunOssConfig aliyunOssConfig,
|
||||||
|
CephConfig cephConfig,
|
||||||
|
MinioConfig minioConfig, MinioClient minioClient,
|
||||||
|
COSClient cosClient, TencentCosConfig tencentCosConfig,
|
||||||
|
QiniuKodoConfig qiniuKodoConfig,
|
||||||
|
ResourcesConfig resourcesConfig) {
|
||||||
|
if (ISysFileService.DfsTypeEnum.FASTDFS.equals(fileServerType)) {
|
||||||
|
return new FastDfsSysFileServiceImpl(fastFileStorageClient, fastDfsConfig);
|
||||||
|
} else if (ISysFileService.DfsTypeEnum.FTP.equals(fileServerType)) {
|
||||||
|
return new FtpFileServiceImpl(ftpConfig);
|
||||||
|
} else if (ISysFileService.DfsTypeEnum.ALIYUN_OSS.equals(fileServerType)) {
|
||||||
|
return new AliyunOssDsfServiceImpl(aliyunOssConfig);
|
||||||
|
} else if (ISysFileService.DfsTypeEnum.CEPH.equals(fileServerType)) {
|
||||||
|
return new CephSysFileServiceImpl(cephConfig);
|
||||||
|
} else if (ISysFileService.DfsTypeEnum.MINIO.equals(fileServerType)) {
|
||||||
|
return new MinioSysFileServiceImpl(minioConfig, minioClient);
|
||||||
|
} else if (ISysFileService.DfsTypeEnum.TENCENT_COS.equals(fileServerType)) {
|
||||||
|
return new TencentCosServiceImpl(cosClient, tencentCosConfig);
|
||||||
|
} else if (ISysFileService.DfsTypeEnum.QINIU_KODO.equals(fileServerType)) {
|
||||||
|
return new QiniuSysFileServiceImpl(qiniuKodoConfig);
|
||||||
|
}
|
||||||
|
return new LocalSysFileServiceImpl(resourcesConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileServerType(ISysFileService.DfsTypeEnum fileServerType) {
|
||||||
|
this.fileServerType = fileServerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
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;
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,14 @@ import java.util.concurrent.TimeUnit;
|
||||||
* @date 2019/8/6 19:02
|
* @date 2019/8/6 19:02
|
||||||
* //@see AliyunMsgUtil
|
* //@see AliyunMsgUtil
|
||||||
*/
|
*/
|
||||||
@Primary
|
|
||||||
@Service()
|
|
||||||
public class AliyunOssDsfServiceImpl implements ISysFileService {
|
public class AliyunOssDsfServiceImpl implements ISysFileService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(AliyunOssDsfServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(AliyunOssDsfServiceImpl.class);
|
||||||
@Autowired
|
private final AliyunOssConfig aliyunOssConfig;
|
||||||
private AliyunOssConfig aliyunOssConfig;
|
|
||||||
|
public AliyunOssDsfServiceImpl(AliyunOssConfig aliyunOssConfig) {
|
||||||
|
this.aliyunOssConfig = aliyunOssConfig;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* demo 地址 https://help.aliyun.com/learn/learningpath/oss.html
|
* demo 地址 https://help.aliyun.com/learn/learningpath/oss.html
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,15 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||||
* 2:ceph存储,使用docker部署 https://www.cnblogs.com/bladeyul/p/10649049.html
|
* 2:ceph存储,使用docker部署 https://www.cnblogs.com/bladeyul/p/10649049.html
|
||||||
* 3:使用docker 搭建 ceph 开发环境,使用aws sdk 存储数据 https://blog.csdn.net/freewebsys/article/details/79553386
|
* 3:使用docker 搭建 ceph 开发环境,使用aws sdk 存储数据 https://blog.csdn.net/freewebsys/article/details/79553386
|
||||||
*/
|
*/
|
||||||
@Service()
|
|
||||||
public class CephSysFileServiceImpl implements ISysFileService {
|
public class CephSysFileServiceImpl implements ISysFileService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(CephSysFileServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(CephSysFileServiceImpl.class);
|
||||||
@Autowired
|
private final CephConfig cephConfig;
|
||||||
private CephConfig cephConfig;
|
|
||||||
|
|
||||||
protected static AmazonS3 amazonS3 = null;
|
protected static AmazonS3 amazonS3 = null;
|
||||||
|
|
||||||
|
public CephSysFileServiceImpl(CephConfig cephConfig) {
|
||||||
|
this.cephConfig = cephConfig;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ceph配置初始化
|
* ceph配置初始化
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -20,16 +20,17 @@ import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @see FastDfsConfig
|
* @see FastDfsConfig
|
||||||
*/
|
*/
|
||||||
//@Primary
|
|
||||||
@Service()
|
|
||||||
public class FastDfsSysFileServiceImpl implements ISysFileService
|
public class FastDfsSysFileServiceImpl implements ISysFileService
|
||||||
{
|
{
|
||||||
private final Logger logger = LoggerFactory.getLogger(FastDfsSysFileServiceImpl.class);
|
private final Logger logger = LoggerFactory.getLogger(FastDfsSysFileServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
private final FastFileStorageClient storageClient;
|
||||||
private FastFileStorageClient storageClient;
|
private final FastDfsConfig fastDfsConfig;
|
||||||
@Autowired
|
|
||||||
private FastDfsConfig fastDfsConfig;
|
public FastDfsSysFileServiceImpl(FastFileStorageClient storageClient, FastDfsConfig fastDfsConfig) {
|
||||||
|
this.storageClient = storageClient;
|
||||||
|
this.fastDfsConfig = fastDfsConfig;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FastDfs文件上传接口
|
* FastDfs文件上传接口
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,12 @@ import java.io.IOException;
|
||||||
* ftp, 如:iis、linux ftp、vsftpd、FileZilla Server,需要自己搭建服务
|
* ftp, 如:iis、linux ftp、vsftpd、FileZilla Server,需要自己搭建服务
|
||||||
* @author dazer
|
* @author dazer
|
||||||
*/
|
*/
|
||||||
@Service()
|
|
||||||
public class FtpFileServiceImpl implements ISysFileService {
|
public class FtpFileServiceImpl implements ISysFileService {
|
||||||
@Autowired
|
private final FtpConfig ftpConfig;
|
||||||
private FtpConfig ftpConfig;
|
|
||||||
|
public FtpFileServiceImpl(FtpConfig ftpConfig) {
|
||||||
|
this.ftpConfig = ftpConfig;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadFile(MultipartFile file) throws Exception {
|
public String uploadFile(MultipartFile file) throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,62 @@ public interface ISysFileService
|
||||||
// pdf
|
// pdf
|
||||||
"pdf" };
|
"pdf" };
|
||||||
|
|
||||||
|
enum DfsTypeEnum {
|
||||||
|
/**
|
||||||
|
* 最原始,文件移动
|
||||||
|
* @see LocalSysFileServiceImpl
|
||||||
|
* 2014-07-06
|
||||||
|
*/
|
||||||
|
DEFAULT,
|
||||||
|
/**
|
||||||
|
* ftp, 如:iis、linux ftp、vsftpd、FileZilla Server,需要自己搭建服务
|
||||||
|
* 这里的FTP要求和主项目在同一个服务器,并且访问路径完全同DEFAULT ,只是DEFAULT: tomcat处理、ftp: 使用 其他ftp工具处理
|
||||||
|
* @see FtpFileServiceImpl
|
||||||
|
* 「「如果使用tomcat,tomcat自己值提供上传能力,不提供访问能力,访问能力比较危险。我们使用nginx 进行代理访问」」
|
||||||
|
* 2019-07-06
|
||||||
|
*/
|
||||||
|
FTP,
|
||||||
|
/**
|
||||||
|
* 淘宝 开发的分布式 dfs, 需要自己搭建服务 (FastDFS)
|
||||||
|
* @see FastDfsSysFileServiceImpl
|
||||||
|
* 2016-09-07
|
||||||
|
*/
|
||||||
|
FASTDFS,
|
||||||
|
/**
|
||||||
|
* aliyun oss https://help.aliyun.com/learn/learningpath/oss.html ,需要购买
|
||||||
|
* 【sts】 【临时授权】 -- 对象存储- 使用签名URL进行临时授权 https://help.aliyun.com/document_detail/32016.html?spm=a2c4g.11186623.6.992.7a943b4aPjkyTA#title-pu8-5o8-x7j
|
||||||
|
* @see AliyunOssDsfServiceImpl
|
||||||
|
* 2019-08-06
|
||||||
|
*/
|
||||||
|
ALIYUN_OSS,
|
||||||
|
/**
|
||||||
|
* CEPH 分布式大数据文件存储系统 http://docs.ceph.org.cn/
|
||||||
|
* @see CephSysFileServiceImpl
|
||||||
|
* 2020-05-06
|
||||||
|
*/
|
||||||
|
CEPH,
|
||||||
|
/**
|
||||||
|
* minio 类似一个阿里云oss、腾讯COS的一个开源、轻量级别的对象存储付;
|
||||||
|
* 英文地址:https://min.io/
|
||||||
|
* 中文地址:http://docs.minio.org.cn/docs/ http://www.minio.org.cn/
|
||||||
|
* 支持对url进行鉴权:【sts】【临时授权】 【Presigned presignedGetObject 预签】 MinIO STS快速入门指南 http://docs.minio.org.cn/docs/master/minio-sts-quickstart-guide
|
||||||
|
* minio SDKS Java Client API参考文档 http://docs.minio.org.cn/docs/master/java-client-api-reference
|
||||||
|
* @see MinioSysFileServiceImpl
|
||||||
|
* 2021-02-09
|
||||||
|
*/
|
||||||
|
MINIO,
|
||||||
|
/**
|
||||||
|
* 腾讯云存储 cos
|
||||||
|
* @see TencentCosServiceImpl
|
||||||
|
*/
|
||||||
|
TENCENT_COS,
|
||||||
|
/**
|
||||||
|
* 七牛 Kodo
|
||||||
|
* @see QiniuSysFileServiceImpl
|
||||||
|
*/
|
||||||
|
QINIU_KODO
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传接口
|
* 文件上传接口
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.io.FileUtil;
|
||||||
import com.ruoyi.common.core.exception.CustomException;
|
import com.ruoyi.common.core.exception.CustomException;
|
||||||
import com.ruoyi.file.config.ResourcesConfig;
|
import com.ruoyi.file.config.ResourcesConfig;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.file.utils.FileUploadUtils;
|
import com.ruoyi.file.utils.FileUploadUtils;
|
||||||
|
|
@ -15,7 +16,6 @@ import java.io.File;
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service()
|
|
||||||
public class LocalSysFileServiceImpl implements ISysFileService
|
public class LocalSysFileServiceImpl implements ISysFileService
|
||||||
{
|
{
|
||||||
private final ResourcesConfig resourcesConfig;
|
private final ResourcesConfig resourcesConfig;
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,15 @@ import java.util.function.Consumer;
|
||||||
* http://docs.minio.org.cn/docs/master/java-client-api-reference#presignedGetObject
|
* http://docs.minio.org.cn/docs/master/java-client-api-reference#presignedGetObject
|
||||||
* MinIO STS快速入门指南 http://docs.minio.org.cn/docs/master/minio-sts-quickstart-guide
|
* MinIO STS快速入门指南 http://docs.minio.org.cn/docs/master/minio-sts-quickstart-guide
|
||||||
*/
|
*/
|
||||||
//@Primary
|
|
||||||
@Service()
|
|
||||||
public class MinioSysFileServiceImpl implements ISysFileService
|
public class MinioSysFileServiceImpl implements ISysFileService
|
||||||
{
|
{
|
||||||
@Autowired
|
private final MinioConfig minioConfig;
|
||||||
private MinioConfig minioConfig;
|
private final MinioClient minioClient;
|
||||||
@Autowired
|
|
||||||
private MinioClient minioClient;
|
public MinioSysFileServiceImpl(MinioConfig minioConfig, MinioClient minioClient) {
|
||||||
|
this.minioConfig = minioConfig;
|
||||||
|
this.minioClient = minioClient;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地文件上传接口
|
* 本地文件上传接口
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,13 @@ import java.io.InputStream;
|
||||||
*
|
*
|
||||||
* 构建时间戳防盗链访问链接: https://developer.qiniu.com/kodo/1239/java#fusion-antileech
|
* 构建时间戳防盗链访问链接: https://developer.qiniu.com/kodo/1239/java#fusion-antileech
|
||||||
*/
|
*/
|
||||||
//@Primary
|
|
||||||
@Service()
|
|
||||||
public class QiniuSysFileServiceImpl implements ISysFileService {
|
public class QiniuSysFileServiceImpl implements ISysFileService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(QiniuSysFileServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(QiniuSysFileServiceImpl.class);
|
||||||
@Autowired
|
private final QiniuKodoConfig qiniuKodoConfig;
|
||||||
private QiniuKodoConfig qiniuKodoConfig;
|
|
||||||
|
public QiniuSysFileServiceImpl(QiniuKodoConfig qiniuKodoConfig) {
|
||||||
|
this.qiniuKodoConfig = qiniuKodoConfig;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadFile(MultipartFile file) throws Exception {
|
public String uploadFile(MultipartFile file) throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import com.qcloud.cos.model.*;
|
||||||
import com.ruoyi.common.core.exception.CustomException;
|
import com.ruoyi.common.core.exception.CustomException;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.file.config.TencentCosConfig;
|
import com.ruoyi.file.config.TencentCosConfig;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
@ -22,8 +21,6 @@ import java.util.List;
|
||||||
* @author yabo
|
* @author yabo
|
||||||
* @see TencentCosConfig
|
* @see TencentCosConfig
|
||||||
*/
|
*/
|
||||||
//@Primary
|
|
||||||
@Service()
|
|
||||||
public class TencentCosServiceImpl implements ISysFileService {
|
public class TencentCosServiceImpl implements ISysFileService {
|
||||||
private final COSClient cosClient;
|
private final COSClient cosClient;
|
||||||
private final TencentCosConfig config;
|
private final TencentCosConfig config;
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ spring:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 127.0.0.1:8848
|
server-addr: 192.168.254.146:8948
|
||||||
namespace: 72b686a1-d9f6-499f-8275-e481b664779e
|
namespace: 83b5e907-a1b8-4a03-ad76-0f2a1f6e8437
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 127.0.0.1:8848
|
server-addr: 192.168.254.146:8948
|
||||||
namespace: 72b686a1-d9f6-499f-8275-e481b664779e
|
namespace: 83b5e907-a1b8-4a03-ad76-0f2a1f6e8437
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
@ -29,59 +29,56 @@ spring:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
|
||||||
|
|
||||||
# 文件服务器之1 本地文件上传
|
|
||||||
file:
|
file:
|
||||||
domain: http://localhost:9300
|
file-server-type: ALIYUN_OSS
|
||||||
prefix: /statics
|
# 文件服务器之1 本地文件上传
|
||||||
path: D:/ruoyi/uploadPath
|
local-file:
|
||||||
|
domain: http://localhost:9300
|
||||||
# 文件服务器之2 ftp
|
prefix: /statics
|
||||||
ftp:
|
path: D:/ruoyi/uploadPath
|
||||||
endpoint: 118.31.2.53
|
# 文件服务器之2 ftp
|
||||||
port: 21
|
ftp:
|
||||||
user-name: lanjinjun
|
endpoint: 118.31.2.53
|
||||||
password:
|
port: 21
|
||||||
domain: https://test53.ourslook.com
|
user-name: lanjinjun
|
||||||
|
password:
|
||||||
|
domain: https://test53.ourslook.com
|
||||||
|
# 文件服务器之4 Minio配置
|
||||||
|
minio:
|
||||||
|
url: http://10.16.58.152:9000
|
||||||
|
accessKey: D99KGE6ZTQXSATTJWU24
|
||||||
|
secretKey: QyVqGnhIQQE734UYSUFlGOZViE6+ZlDEfUG3NjhJ
|
||||||
|
bucketName: appt-file
|
||||||
|
domain: https://yq666.bj.gov.cn
|
||||||
|
expiry-duration: 32400
|
||||||
|
# 文件服务器之5 aliyun oss
|
||||||
|
aliyun-oss:
|
||||||
|
access-key: LTAI4GDQSbwgmbsRxxbDXnKT
|
||||||
|
secret-key: I1xYosCsIf4YgHeFbWUOU4faImeWD2
|
||||||
|
bucket-name: react-yuebaoxiao-pro
|
||||||
|
endpoint: oss-cn-shanghai.aliyuncs.com
|
||||||
|
domain: https://react-yuebaoxiao-pro.oss-cn-shanghai.aliyuncs.com
|
||||||
|
expiry-duration: 32400
|
||||||
|
# 文件服务器之6 qiniu 七牛 kodo
|
||||||
|
qiniu:
|
||||||
|
access-key: pRYrSe_EW4sJHsQ6JyuiRYShA2JCLKtMhT-N4TQD
|
||||||
|
secret-key: CwTEh1kSLBdxBhIWfFz6h1GgDSokx97CYEV0cC1O
|
||||||
|
bucket-name: guangdong-oss
|
||||||
|
domain: http://guangdong-oss.ityun.ltd
|
||||||
|
expiry-duration: 32400
|
||||||
|
# 文件服务器之7 tencent cos 文件存储
|
||||||
|
tencent-cos:
|
||||||
|
access-key: AKIDX9hNAzpdUI0XyRpASj098xa7uYzOekmh
|
||||||
|
secret-key: sW5VgkdHlDYqy01xiGbkjV5TghUEvYEw
|
||||||
|
endpoint: ap-chengdu
|
||||||
|
bucket-name: tencent-cloud-cos-dazer-1253883700
|
||||||
|
domain: https://cos.ityun.ltd
|
||||||
|
expiry-duration: 32400
|
||||||
# 文件服务器之3 FastDFS配置
|
# 文件服务器之3 FastDFS配置
|
||||||
|
##### fdfs 配置路径特殊, 为了兼容fastdfs
|
||||||
fdfs:
|
fdfs:
|
||||||
soTimeout: 3000
|
soTimeout: 3000
|
||||||
connectTimeout: 5000
|
connectTimeout: 5000
|
||||||
trackerList: 47.99.175.191:22122
|
trackerList: 47.99.175.191:22122
|
||||||
domain: http://47.99.175.191:8888
|
domain: http://47.99.175.191:8888
|
||||||
token-secret-key: test@test
|
token-secret-key: test@test
|
||||||
|
|
||||||
# 文件服务器之4 Minio配置
|
|
||||||
minio:
|
|
||||||
url: http://10.16.58.152:9000
|
|
||||||
accessKey: D99KGE6ZTQXSATTJWU24
|
|
||||||
secretKey: QyVqGnhIQQE734UYSUFlGOZViE6+ZlDEfUG3NjhJ
|
|
||||||
bucketName: appt-file
|
|
||||||
domain: https://yq666.bj.gov.cn
|
|
||||||
expiry-duration: 32400
|
|
||||||
|
|
||||||
# 文件服务器之5 aliyun oss
|
|
||||||
aliyun-oss:
|
|
||||||
access-key: LTAI4GDQSbwgmbsRxxbDXnKT
|
|
||||||
secret-key: I1xYosCsIf4YgHeFbWUOU4faImeWD2
|
|
||||||
bucket-name: react-yuebaoxiao-pro
|
|
||||||
endpoint: oss-cn-shanghai.aliyuncs.com
|
|
||||||
domain: https://react-yuebaoxiao-pro.oss-cn-shanghai.aliyuncs.com
|
|
||||||
expiry-duration: 32400
|
|
||||||
|
|
||||||
# 文件服务器之6 qiniu 七牛 kodo
|
|
||||||
qiniu:
|
|
||||||
access-key: pRYrSe_EW4sJHsQ6JyuiRYShA2JCLKtMhT-N4TQD
|
|
||||||
secret-key: CwTEh1kSLBdxBhIWfFz6h1GgDSokx97CYEV0cC1O
|
|
||||||
bucket-name: guangdong-oss
|
|
||||||
domain: http://guangdong-oss.ityun.ltd
|
|
||||||
expiry-duration: 32400
|
|
||||||
|
|
||||||
# 文件服务器之7 tencent cos 文件存储
|
|
||||||
tencent-cos:
|
|
||||||
access-key: AKIDX9hNAzpdUI0XyRpASj098xa7uYzOekmh
|
|
||||||
secret-key: sW5VgkdHlDYqy01xiGbkjV5TghUEvYEw
|
|
||||||
endpoint: ap-chengdu
|
|
||||||
bucket-name: tencent-cloud-cos-dazer-1253883700
|
|
||||||
domain: https://cos.ityun.ltd
|
|
||||||
expiry-duration: 32400
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue