diff --git a/pigx-common/pigx-common-oss/pom.xml b/pigx-common/pigx-common-oss/pom.xml
index 102b7dc9c..c586e56f3 100755
--- a/pigx-common/pigx-common-oss/pom.xml
+++ b/pigx-common/pigx-common-oss/pom.xml
@@ -1,24 +1,28 @@
- 4.0.0
-
- com.pig4cloud
- pigx-common
- 4.3.0
-
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ com.pig4cloud
+ pigx-common
+ 4.3.0
+
- pigx-common-oss
- jar
+ pigx-common-oss
+ jar
- pigx 文件系统依赖
+ pigx 文件系统依赖
-
-
- com.amazonaws
- aws-java-sdk-s3
- ${aws.version}
-
-
+
+
+ com.amazonaws
+ aws-java-sdk-s3
+ ${aws.version}
+
+
+ cn.hutool
+ hutool-core
+
+
diff --git a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/FileAutoConfiguration.java b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/FileAutoConfiguration.java
new file mode 100755
index 000000000..13a89d1ee
--- /dev/null
+++ b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/FileAutoConfiguration.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.common.file;
+
+import com.pig4cloud.pigx.common.file.core.FileProperties;
+import com.pig4cloud.pigx.common.file.local.LocalFileAutoConfiguration;
+import com.pig4cloud.pigx.common.file.oss.OssAutoConfiguration;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Import;
+
+/**
+ * aws 自动配置类
+ *
+ * @author lengleng
+ * @author 858695266
+ */
+@Import({ LocalFileAutoConfiguration.class, OssAutoConfiguration.class })
+@EnableConfigurationProperties({ FileProperties.class })
+public class FileAutoConfiguration {
+
+}
diff --git a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/core/FileProperties.java b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/core/FileProperties.java
new file mode 100755
index 000000000..d4528fe74
--- /dev/null
+++ b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/core/FileProperties.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.common.file.core;
+
+import com.pig4cloud.pigx.common.file.local.LocalFileProperties;
+import com.pig4cloud.pigx.common.file.oss.OssProperties;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * 文件 配置信息
+ *
+ * @author lengleng
+ *
+ * bucket 设置公共读权限
+ */
+@Data
+@ConfigurationProperties(prefix = "file")
+public class FileProperties {
+
+ /**
+ * 默认的存储桶名称
+ */
+ private String bucketName = "payerp";
+
+ /**
+ * 本地文件配置信息
+ */
+ private LocalFileProperties local;
+
+ /**
+ * oss 文件配置信息
+ */
+ private OssProperties oss;
+
+}
diff --git a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/core/FileTemplate.java b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/core/FileTemplate.java
new file mode 100644
index 000000000..f789b7829
--- /dev/null
+++ b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/core/FileTemplate.java
@@ -0,0 +1,87 @@
+package com.pig4cloud.pigx.common.file.core;
+
+import com.amazonaws.services.s3.model.Bucket;
+import com.amazonaws.services.s3.model.S3Object;
+import com.amazonaws.services.s3.model.S3ObjectSummary;
+import org.springframework.beans.factory.InitializingBean;
+
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * 文件操作模板
+ *
+ * @author lengleng
+ * @date 2022/4/19
+ */
+public interface FileTemplate extends InitializingBean {
+
+ /**
+ * 创建bucket
+ * @param bucketName bucket名称
+ */
+ void createBucket(String bucketName);
+
+ /**
+ * 获取全部bucket
+ *
+ *
+ * API Documentation
+ */
+ List getAllBuckets();
+
+ /**
+ * @param bucketName bucket名称
+ * @see
+ */
+ void removeBucket(String bucketName);
+
+ /**
+ * 上传文件
+ * @param bucketName bucket名称
+ * @param objectName 文件名称
+ * @param stream 文件流
+ * @param contextType 文件类型
+ * @throws Exception
+ */
+ void putObject(String bucketName, String objectName, InputStream stream, String contextType) throws Exception;
+
+ /**
+ * 上传文件
+ * @param bucketName bucket名称
+ * @param objectName 文件名称
+ * @param stream 文件流
+ * @param contextType 文件类型
+ * @throws Exception
+ */
+ void putObject(String bucketName, String objectName, InputStream stream) throws Exception;
+
+ /**
+ * 获取文件
+ * @param bucketName bucket名称
+ * @param objectName 文件名称
+ * @return 二进制流 API Documentation
+ */
+ S3Object getObject(String bucketName, String objectName);
+
+ void removeObject(String bucketName, String objectName) throws Exception;
+
+ /**
+ * @throws Exception
+ */
+ @Override
+ default void afterPropertiesSet() throws Exception {
+ }
+
+ /**
+ * 根据文件前置查询文件
+ * @param bucketName bucket名称
+ * @param prefix 前缀
+ * @param recursive 是否递归查询
+ * @return S3ObjectSummary 列表
+ * @see AWS
+ * API Documentation
+ */
+ List getAllObjectsByPrefix(String bucketName, String prefix, boolean recursive);
+
+}
diff --git a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/local/LocalFileAutoConfiguration.java b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/local/LocalFileAutoConfiguration.java
new file mode 100755
index 000000000..577b13a6c
--- /dev/null
+++ b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/local/LocalFileAutoConfiguration.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.common.file.local;
+
+import com.pig4cloud.pigx.common.file.core.FileProperties;
+import com.pig4cloud.pigx.common.file.core.FileTemplate;
+import lombok.AllArgsConstructor;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * aws 自动配置类
+ *
+ * @author lengleng
+ * @author 858695266
+ */
+@AllArgsConstructor
+public class LocalFileAutoConfiguration {
+
+ private final FileProperties properties;
+
+ @Bean
+ @ConditionalOnMissingBean(LocalFileTemplate.class)
+ @ConditionalOnProperty(name = "file.local.enable", havingValue = "true", matchIfMissing = true)
+ public FileTemplate localFileTemplate() {
+ return new LocalFileTemplate(properties);
+ }
+
+}
diff --git a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/local/LocalFileProperties.java b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/local/LocalFileProperties.java
new file mode 100755
index 000000000..b6c285b52
--- /dev/null
+++ b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/local/LocalFileProperties.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.common.file.local;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * 本地文件 配置信息
+ *
+ * @author lengleng
+ *
+ * bucket 设置公共读权限
+ */
+@Data
+@ConfigurationProperties(prefix = "local")
+public class LocalFileProperties {
+
+ /**
+ * 是否开启
+ */
+ private boolean enable;
+
+ /**
+ * 默认路径
+ */
+ private String basePath;
+
+}
diff --git a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/local/LocalFileTemplate.java b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/local/LocalFileTemplate.java
new file mode 100644
index 000000000..f330c264e
--- /dev/null
+++ b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/local/LocalFileTemplate.java
@@ -0,0 +1,137 @@
+package com.pig4cloud.pigx.common.file.local;
+
+import cn.hutool.core.io.FileUtil;
+import com.amazonaws.services.s3.model.Bucket;
+import com.amazonaws.services.s3.model.S3Object;
+import com.amazonaws.services.s3.model.S3ObjectSummary;
+import com.pig4cloud.pigx.common.file.core.FileProperties;
+import com.pig4cloud.pigx.common.file.core.FileTemplate;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 本地文件读取模式
+ *
+ * @author lengleng
+ * @date 2022/4/19
+ */
+@RequiredArgsConstructor
+public class LocalFileTemplate implements FileTemplate {
+
+ private final FileProperties properties;
+
+ /**
+ * 创建bucket
+ * @param bucketName bucket名称
+ */
+ @Override
+ public void createBucket(String bucketName) {
+ FileUtil.mkdir(properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName);
+ }
+
+ /**
+ * 获取全部bucket
+ *
+ *
+ * API Documentation
+ */
+ @Override
+ public List getAllBuckets() {
+ return Arrays.stream(FileUtil.ls(properties.getLocal().getBasePath())).filter(FileUtil::isDirectory)
+ .map(dir -> new Bucket(dir.getName())).collect(Collectors.toList());
+ }
+
+ /**
+ * @param bucketName bucket名称
+ * @see
+ */
+ @Override
+ public void removeBucket(String bucketName) {
+ FileUtil.del(properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName);
+ }
+
+ /**
+ * 上传文件
+ * @param bucketName bucket名称
+ * @param objectName 文件名称
+ * @param stream 文件流
+ * @param contextType 文件类型
+ */
+ @Override
+ public void putObject(String bucketName, String objectName, InputStream stream, String contextType) {
+ // 当 Bucket 不存在时创建
+ String dir = properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName;
+ if (!FileUtil.isDirectory(properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName)) {
+ createBucket(bucketName);
+ }
+
+ // 写入文件
+ File file = FileUtil.file(dir + FileUtil.FILE_SEPARATOR + objectName);
+ FileUtil.writeFromStream(stream, file);
+ }
+
+ /**
+ * 获取文件
+ * @param bucketName bucket名称
+ * @param objectName 文件名称
+ * @return 二进制流 API Documentation
+ */
+ @Override
+ @SneakyThrows
+ public S3Object getObject(String bucketName, String objectName) {
+ String dir = properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName;
+ S3Object s3Object = new S3Object();
+ s3Object.setObjectContent(FileUtil.getInputStream(dir + FileUtil.FILE_SEPARATOR + objectName));
+ return s3Object;
+ }
+
+ /**
+ * @param bucketName
+ * @param objectName
+ * @throws Exception
+ */
+ @Override
+ public void removeObject(String bucketName, String objectName) throws Exception {
+ String dir = properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName;
+ FileUtil.del(dir + FileUtil.FILE_SEPARATOR + objectName);
+ }
+
+ /**
+ * 上传文件
+ * @param bucketName bucket名称
+ * @param objectName 文件名称
+ * @param stream 文件流
+ * @throws Exception
+ */
+ @Override
+ public void putObject(String bucketName, String objectName, InputStream stream) throws Exception {
+ putObject(bucketName, objectName, stream, null);
+ }
+
+ /**
+ * 根据文件前置查询文件
+ * @param bucketName bucket名称
+ * @param prefix 前缀
+ * @param recursive 是否递归查询
+ * @return S3ObjectSummary 列表
+ * @see AWS
+ * API Documentation
+ */
+ @Override
+ public List getAllObjectsByPrefix(String bucketName, String prefix, boolean recursive) {
+ String dir = properties.getLocal().getBasePath() + FileUtil.FILE_SEPARATOR + bucketName;
+
+ return Arrays.stream(FileUtil.ls(dir)).filter(file -> file.getName().startsWith(prefix)).map(file -> {
+ S3ObjectSummary summary = new S3ObjectSummary();
+ summary.setKey(file.getName());
+ return new S3ObjectSummary();
+ }).collect(Collectors.toList());
+ }
+
+}
diff --git a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/OssAutoConfiguration.java b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/OssAutoConfiguration.java
similarity index 71%
rename from pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/OssAutoConfiguration.java
rename to pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/OssAutoConfiguration.java
index 8df6256e7..47d9ba465 100755
--- a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/OssAutoConfiguration.java
+++ b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/OssAutoConfiguration.java
@@ -15,15 +15,17 @@
* Author: lengleng (wangiegie@gmail.com)
*/
-package com.pig4cloud.pigx.common.oss;
+package com.pig4cloud.pigx.common.file.oss;
-import com.pig4cloud.pigx.common.oss.http.OssEndpoint;
-import com.pig4cloud.pigx.common.oss.service.OssTemplate;
+import com.pig4cloud.pigx.common.file.core.FileProperties;
+import com.pig4cloud.pigx.common.file.core.FileTemplate;
+import com.pig4cloud.pigx.common.file.oss.http.OssEndpoint;
+import com.pig4cloud.pigx.common.file.oss.service.OssTemplate;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
/**
* aws 自动配置类
@@ -32,20 +34,20 @@ import org.springframework.context.annotation.Bean;
* @author 858695266
*/
@AllArgsConstructor
-@EnableConfigurationProperties({ OssProperties.class })
public class OssAutoConfiguration {
- private final OssProperties properties;
+ private final FileProperties properties;
@Bean
+ @Primary
@ConditionalOnMissingBean(OssTemplate.class)
- @ConditionalOnProperty(name = "oss.enable", havingValue = "true", matchIfMissing = true)
- public OssTemplate ossTemplate() {
+ @ConditionalOnProperty(name = "file.oss.enable", havingValue = "true")
+ public FileTemplate ossTemplate() {
return new OssTemplate(properties);
}
@Bean
- @ConditionalOnProperty(name = "oss.info", havingValue = "true")
+ @ConditionalOnProperty(name = "file.oss.info", havingValue = "true")
public OssEndpoint ossEndpoint(OssTemplate template) {
return new OssEndpoint(template);
}
diff --git a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/OssProperties.java b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/OssProperties.java
similarity index 94%
rename from pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/OssProperties.java
rename to pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/OssProperties.java
index 4ebacb1c9..6539304ab 100755
--- a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/OssProperties.java
+++ b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/OssProperties.java
@@ -15,7 +15,7 @@
* Author: lengleng (wangiegie@gmail.com)
*/
-package com.pig4cloud.pigx.common.oss;
+package com.pig4cloud.pigx.common.file.oss;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -72,11 +72,6 @@ public class OssProperties {
*/
private String secretKey;
- /**
- * 默认的存储桶名称
- */
- private String bucketName = "payerp";
-
/**
* 最大线程数,默认: 100
*/
diff --git a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/http/OssEndpoint.java b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/http/OssEndpoint.java
similarity index 97%
rename from pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/http/OssEndpoint.java
rename to pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/http/OssEndpoint.java
index 8d85459e7..9f51d9865 100755
--- a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/http/OssEndpoint.java
+++ b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/http/OssEndpoint.java
@@ -15,12 +15,12 @@
* Author: lengleng (wangiegie@gmail.com)
*/
-package com.pig4cloud.pigx.common.oss.http;
+package com.pig4cloud.pigx.common.file.oss.http;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.S3ObjectSummary;
-import com.pig4cloud.pigx.common.oss.service.OssTemplate;
+import com.pig4cloud.pigx.common.file.oss.service.OssTemplate;
import lombok.AllArgsConstructor;
import lombok.Cleanup;
import lombok.SneakyThrows;
diff --git a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/service/OssTemplate.java b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/service/OssTemplate.java
similarity index 91%
rename from pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/service/OssTemplate.java
rename to pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/service/OssTemplate.java
index fff705df7..44417c8b6 100755
--- a/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/oss/service/OssTemplate.java
+++ b/pigx-common/pigx-common-oss/src/main/java/com/pig4cloud/pigx/common/file/oss/service/OssTemplate.java
@@ -15,7 +15,7 @@
* Author: lengleng (wangiegie@gmail.com)
*/
-package com.pig4cloud.pigx.common.oss.service;
+package com.pig4cloud.pigx.common.file.oss.service;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentials;
@@ -27,7 +27,8 @@ import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.*;
import com.amazonaws.util.IOUtils;
-import com.pig4cloud.pigx.common.oss.OssProperties;
+import com.pig4cloud.pigx.common.file.core.FileProperties;
+import com.pig4cloud.pigx.common.file.core.FileTemplate;
import lombok.Cleanup;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
@@ -47,9 +48,9 @@ import java.util.*;
* @since 1.0
*/
@RequiredArgsConstructor
-public class OssTemplate implements InitializingBean {
+public class OssTemplate implements InitializingBean, FileTemplate {
- private final OssProperties ossProperties;
+ private final FileProperties properties;
private AmazonS3 amazonS3;
@@ -220,16 +221,16 @@ public class OssTemplate implements InitializingBean {
@Override
public void afterPropertiesSet() {
ClientConfiguration clientConfiguration = new ClientConfiguration();
- clientConfiguration.setMaxConnections(ossProperties.getMaxConnections());
+ clientConfiguration.setMaxConnections(properties.getOss().getMaxConnections());
AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(
- ossProperties.getEndpoint(), ossProperties.getRegion());
- AWSCredentials awsCredentials = new BasicAWSCredentials(ossProperties.getAccessKey(),
- ossProperties.getSecretKey());
+ properties.getOss().getEndpoint(), properties.getOss().getRegion());
+ AWSCredentials awsCredentials = new BasicAWSCredentials(properties.getOss().getAccessKey(),
+ properties.getOss().getSecretKey());
AWSCredentialsProvider awsCredentialsProvider = new AWSStaticCredentialsProvider(awsCredentials);
this.amazonS3 = AmazonS3Client.builder().withEndpointConfiguration(endpointConfiguration)
.withClientConfiguration(clientConfiguration).withCredentials(awsCredentialsProvider)
- .disableChunkedEncoding().withPathStyleAccessEnabled(ossProperties.getPathStyleAccess()).build();
+ .disableChunkedEncoding().withPathStyleAccessEnabled(properties.getOss().getPathStyleAccess()).build();
}
}
diff --git a/pigx-common/pigx-common-oss/src/main/resources/META-INF/spring.factories b/pigx-common/pigx-common-oss/src/main/resources/META-INF/spring.factories
index 94331536e..1a08633f4 100755
--- a/pigx-common/pigx-common-oss/src/main/resources/META-INF/spring.factories
+++ b/pigx-common/pigx-common-oss/src/main/resources/META-INF/spring.factories
@@ -1,2 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
- com.pig4cloud.pigx.common.oss.OssAutoConfiguration
\ No newline at end of file
+ com.pig4cloud.pigx.common.file.FileAutoConfiguration
diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysFileServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysFileServiceImpl.java
index cd1af9ea8..b68e85374 100644
--- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysFileServiceImpl.java
+++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysFileServiceImpl.java
@@ -26,8 +26,8 @@ import com.pig4cloud.pigx.admin.api.entity.SysFile;
import com.pig4cloud.pigx.admin.mapper.SysFileMapper;
import com.pig4cloud.pigx.admin.service.SysFileService;
import com.pig4cloud.pigx.common.core.util.R;
-import com.pig4cloud.pigx.common.oss.OssProperties;
-import com.pig4cloud.pigx.common.oss.service.OssTemplate;
+import com.pig4cloud.pigx.common.file.core.FileProperties;
+import com.pig4cloud.pigx.common.file.core.FileTemplate;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
@@ -51,9 +51,9 @@ import java.util.Map;
@AllArgsConstructor
public class SysFileServiceImpl extends ServiceImpl implements SysFileService {
- private final OssProperties ossProperties;
+ private final FileTemplate fileTemplate;
- private final OssTemplate minioTemplate;
+ private final FileProperties properties;
/**
* 上传文件
@@ -64,12 +64,12 @@ public class SysFileServiceImpl extends ServiceImpl impl
public R uploadFile(MultipartFile file) {
String fileName = IdUtil.simpleUUID() + StrUtil.DOT + FileUtil.extName(file.getOriginalFilename());
Map resultMap = new HashMap<>(4);
- resultMap.put("bucketName", ossProperties.getBucketName());
+ resultMap.put("bucketName", properties.getBucketName());
resultMap.put("fileName", fileName);
- resultMap.put("url", String.format("/admin/sys-file/%s/%s", ossProperties.getBucketName(), fileName));
+ resultMap.put("url", String.format("/admin/sys-file/%s/%s", properties.getBucketName(), fileName));
try (InputStream inputStream = file.getInputStream()) {
- minioTemplate.putObject(ossProperties.getBucketName(), fileName, inputStream, file.getContentType());
+ fileTemplate.putObject(properties.getBucketName(), fileName, inputStream, file.getContentType());
// 文件管理数据记录,收集管理追踪文件
fileLog(file, fileName);
}
@@ -88,7 +88,7 @@ public class SysFileServiceImpl extends ServiceImpl impl
*/
@Override
public void getFile(String bucket, String fileName, HttpServletResponse response) {
- try (S3Object s3Object = minioTemplate.getObject(bucket, fileName)) {
+ try (S3Object s3Object = fileTemplate.getObject(bucket, fileName)) {
response.setContentType("application/octet-stream; charset=UTF-8");
IoUtil.copy(s3Object.getObjectContent(), response.getOutputStream());
}
@@ -107,7 +107,7 @@ public class SysFileServiceImpl extends ServiceImpl impl
@Transactional(rollbackFor = Exception.class)
public Boolean deleteFile(Long id) {
SysFile file = this.getById(id);
- minioTemplate.removeObject(ossProperties.getBucketName(), file.getFileName());
+ fileTemplate.removeObject(properties.getBucketName(), file.getFileName());
return this.removeById(id);
}
@@ -122,7 +122,7 @@ public class SysFileServiceImpl extends ServiceImpl impl
sysFile.setOriginal(file.getOriginalFilename());
sysFile.setFileSize(file.getSize());
sysFile.setType(FileUtil.extName(file.getOriginalFilename()));
- sysFile.setBucketName(ossProperties.getBucketName());
+ sysFile.setBucketName(properties.getBucketName());
this.save(sysFile);
}
diff --git a/pigx-visual/pigx-bi-platform/src/main/java/com/pig4cloud/pigx/ureport/config/UreportExtConfig.java b/pigx-visual/pigx-bi-platform/src/main/java/com/pig4cloud/pigx/ureport/config/UreportExtConfig.java
index 27cf097b2..8a14d0cf1 100755
--- a/pigx-visual/pigx-bi-platform/src/main/java/com/pig4cloud/pigx/ureport/config/UreportExtConfig.java
+++ b/pigx-visual/pigx-bi-platform/src/main/java/com/pig4cloud/pigx/ureport/config/UreportExtConfig.java
@@ -2,8 +2,9 @@ package com.pig4cloud.pigx.ureport.config;
import com.bstek.ureport.UReportPropertyPlaceholderConfigurer;
import com.bstek.ureport.provider.report.ReportProvider;
-import com.pig4cloud.pigx.common.oss.OssProperties;
-import com.pig4cloud.pigx.common.oss.service.OssTemplate;
+import com.pig4cloud.pigx.common.file.core.FileProperties;
+import com.pig4cloud.pigx.common.file.core.FileTemplate;
+import com.pig4cloud.pigx.common.file.oss.service.OssTemplate;
import com.pig4cloud.pigx.ureport.processor.UReportPropertyPlaceholderConfigurerPlus;
import com.pig4cloud.pigx.ureport.provider.DfsReportProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -26,8 +27,8 @@ import java.util.Locale;
public class UreportExtConfig {
@Bean
- public ReportProvider dfsReportProvider(OssTemplate ossTemplate, OssProperties properties) {
- return new DfsReportProvider(ossTemplate, properties);
+ public ReportProvider dfsReportProvider(FileTemplate template, FileProperties properties) {
+ return new DfsReportProvider(template, properties);
}
@Bean
diff --git a/pigx-visual/pigx-bi-platform/src/main/java/com/pig4cloud/pigx/ureport/provider/DfsReportProvider.java b/pigx-visual/pigx-bi-platform/src/main/java/com/pig4cloud/pigx/ureport/provider/DfsReportProvider.java
index 0e50f43f4..4dd86a626 100755
--- a/pigx-visual/pigx-bi-platform/src/main/java/com/pig4cloud/pigx/ureport/provider/DfsReportProvider.java
+++ b/pigx-visual/pigx-bi-platform/src/main/java/com/pig4cloud/pigx/ureport/provider/DfsReportProvider.java
@@ -4,8 +4,8 @@ import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import com.bstek.ureport.provider.report.ReportFile;
import com.bstek.ureport.provider.report.ReportProvider;
-import com.pig4cloud.pigx.common.oss.OssProperties;
-import com.pig4cloud.pigx.common.oss.service.OssTemplate;
+import com.pig4cloud.pigx.common.file.core.FileProperties;
+import com.pig4cloud.pigx.common.file.core.FileTemplate;
import lombok.Cleanup;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -30,20 +30,20 @@ public class DfsReportProvider implements ReportProvider {
*/
private static final String PREFIX = "oss_";
- private final OssTemplate ossTemplate;
+ private final FileTemplate fileTemplate;
- private final OssProperties properties;
+ private final FileProperties properties;
@Override
public InputStream loadReport(String file) {
- S3Object object = ossTemplate.getObject(properties.getBucketName(), file);
+ S3Object object = fileTemplate.getObject(properties.getBucketName(), file);
return object.getObjectContent();
}
@Override
public void deleteReport(String file) {
try {
- ossTemplate.removeObject(properties.getBucketName(), file);
+ fileTemplate.removeObject(properties.getBucketName(), file);
}
catch (Exception e) {
log.error("文件删除失败 ", e);
@@ -52,7 +52,7 @@ public class DfsReportProvider implements ReportProvider {
@Override
public List getReportFiles() {
- List objectSummaryList = ossTemplate.getAllObjectsByPrefix(properties.getBucketName(), PREFIX,
+ List objectSummaryList = fileTemplate.getAllObjectsByPrefix(properties.getBucketName(), PREFIX,
true);
return objectSummaryList.stream()
@@ -66,7 +66,7 @@ public class DfsReportProvider implements ReportProvider {
try {
@Cleanup
InputStream inputStream = IOUtils.toInputStream(content);
- ossTemplate.putObject(properties.getBucketName(), file, inputStream);
+ fileTemplate.putObject(properties.getBucketName(), file, inputStream);
}
catch (Exception e) {
log.error("文件上传失败", e);