feat: support wfc-modules-file
This commit is contained in:
1 parent
594f416b77
commit
935f868f26
5 files changed
+69
-78
No files matched your search
@@ -93,7 +93,7 @@ INSERT INTO `config_info` VALUES (64, 'wfc-monitor-prod.yml', 'DEFAULT_GROUP', '
|
||||
INSERT INTO `config_info` VALUES (65, 'wfc-system-prod.yml', 'DEFAULT_GROUP', '# spring配置\nspring:\n redis:\n host: wfc-redis\n port: 6379\n password:\n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: admin\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n connectTimeout: 30000\n socketTimeout: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://wfc-mysql:3306/wfc_system_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: 123456\n # 从库数据源\n # slave:\n # username: \n # password: \n # url: \n # driver-class-name: \n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: org.wfc.system\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# swagger配置\nswagger:\n title: 系统模块接口文档\n license: Powered By wfc\n licenseUrl: https://wfc.vip', 'a355587121f711511c9010a4a8c0d797', '2024-12-13 11:52:34', '2024-12-13 11:54:49', NULL, '192.168.2.116', '', 'wfc-prod', '系统模块', '', '', 'yaml', '', '');
|
||||
INSERT INTO `config_info` VALUES (66, 'wfc-gen-prod.yml', 'DEFAULT_GROUP', '# spring配置\nspring:\n redis:\n host: wfc-redis\n port: 6379\n password:\n datasource:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://wfc-mysql:3306/wfc_system_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: 123456\n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: org.wfc.gen.domain\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# swagger配置\nswagger:\n title: 代码生成接口文档\n license: Powered By wfc\n licenseUrl: https://wfc.vip\n\n# 代码生成\ngen:\n # 作者\n author: wfc\n # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool\n packageName: org.wfc.system\n # 自动去除表前缀,默认是false\n autoRemovePre: false\n # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)\n tablePrefix: sys_\n', '5ec7d9b8eb46eca656316e5f817aadb2', '2024-12-13 11:52:34', '2024-12-13 11:55:28', NULL, '192.168.2.116', '', 'wfc-prod', '代码生成', '', '', 'yaml', '', '');
|
||||
INSERT INTO `config_info` VALUES (67, 'wfc-job-prod.yml', 'DEFAULT_GROUP', '# spring配置\nspring:\n redis:\n host: wfc-redis\n port: 6379\n password: \n datasource:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://wfc-mysql:3306/wfc_system_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: 123456\n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: org.wfc.job.domain\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# swagger配置\nswagger:\n title: 定时任务接口文档\n license: Powered By wfc\n licenseUrl: https://wfc.vip\n', '1376deec876c0878df743b4d96c7f125', '2024-12-13 11:52:34', '2024-12-13 11:56:07', NULL, '192.168.2.116', '', 'wfc-prod', '定时任务', '', '', 'yaml', '', '');
|
||||
INSERT INTO `config_info` VALUES (68, 'wfc-file-prod.yml', 'DEFAULT_GROUP', '# 本地文件上传 \nfile:\n domain: http://127.0.0.1:9300\n path: /home/wfc/upload\n prefix: /statics\n\n# FastDFS配置\nfdfs:\n domain: http://8.129.231.12\n soTimeout: 3000\n connectTimeout: 2000\n trackerList: 8.129.231.12:22122\n\n# Minio配置\nminio:\n url: http://8.129.231.12:9000\n accessKey: minioadmin\n secretKey: minioadmin\n bucketName: test', '580197933f0f0b2ba468a0916b911d4b', '2024-12-13 11:52:34', '2024-12-13 11:57:18', NULL, '192.168.2.116', '', 'wfc-prod', '文件服务', '', '', 'yaml', '', '');
|
||||
INSERT INTO `config_info` VALUES (68, 'wfc-file-prod.yml', 'DEFAULT_GROUP', '# 本地文件上传 \nfile:\n domain: wfc-file:9201\n path: /opt/wfc/upload\n prefix: /statics\n\n# FastDFS配置\nfdfs:\n domain: http://wfc-file\n soTimeout: 3000\n connectTimeout: 2000\n trackerList: wfc-file:22122\n\n# Minio配置\nminio:\n url: http://wfc-file:9000\n accessKey: minioadmin\n secretKey: minioadmin\n bucketName: test', '788c4d2b226a744eefc465bf31c3824b', '2024-12-13 11:52:34', '2025-01-07 12:15:07', NULL, '172.19.0.1', '', 'wfc-prod', '文件服务', '', '', 'yaml', '', '');
|
||||
INSERT INTO `config_info` VALUES (69, 'wfc-user-prod.yml', 'DEFAULT_GROUP', '# spring配置\nspring:\n redis:\n host: wfc-redis\n port: 6379\n password:\n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: admin\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n connectTimeout: 30000\n socketTimeout: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://wfc-mysql:3306/wfc_user_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: 123456\n # 从库数据源\n # slave:\n # username:\n # password:\n # url:\n # driver-class-name:\n\n# mybatis配置\nmybatis:\n # 搜索指定包别名\n typeAliasesPackage: org.wfc.user\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapperLocations: classpath:mapper/**/*.xml\n\n# swagger配置\nswagger:\n title: 系统模块接口文档\n license: Powered By wfc\n licenseUrl: https://wfc.vip', 'db8c5a7eeebb0d57d180d1a97ad6226e', '2024-12-28 19:17:13', '2024-12-28 19:17:13', NULL, '172.19.0.1', '', 'wfc-prod', '用户平台模块', NULL, NULL, 'yaml', NULL, '');
|
||||
INSERT INTO `config_info` VALUES (70, 'wfc-payment-prod.yml', 'DEFAULT_GROUP', '# spring配置\nspring:\n application:\n name: wfc-payment\n cloud:\n nacos:\n discovery:\n server-addr: ${NACOS_SERVER_ADDR:wfc-nacos}:${NACOS_SERVER_PORT:8848}\n namespace: ${NACOS_NAMESPACE:wfc-prod}\n \n main:\n allow-bean-definition-overriding: true\n \n redis:\n host: wfc-redis\n port: 6379\n password:\n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: admin\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n connectTimeout: 30000\n socketTimeout: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://wfc-mysql:3306/wfc_user_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: 123456\n # 从库数据源\n # slave:\n # username:\n # password:\n # url:\n # driver-class-name:\n\n# mybatis-plus配置\nmybatis-plus:\n # 搜索指定包别名\n type-aliases-package: org.wfc.payment\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapper-locations: classpath:mapper/**/*.xml\n global-config:\n db-config:\n logic-delete-field: del_flag\n logic-delete-value: 1\n logic-not-delete-value: 0\n\n# swagger配置\nswagger:\n title: 系统模块接口文档\n license: Powered By wfc\n licenseUrl: https://wfc.vip\n\nlogging:\n level:\n root: INFO\n org.springframework.web: INFO\n org.mybatis.mapper: DEBUG\n com.github.binarywang: DEBUG\n\nwxpay:\n appId: wxd678efh567hg6787\n mchId: 1230000109\n mchKey: 1525342aa\n subAppId: #服务商模式下的子商户公众账号ID\n subMchId: #服务商模式下的子商户号 \n keyPath: /opt/wfc/conf/wxpay/wxpay_key.pem\n useSandboxEnv: true\n\nalipay:\n appId: 121412414112\n privateKey: MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC3/5tHX5ioibCWXzUYVVIgd0wexio5CbRITNQ2saPOb17jioe0Q5Qu/xjcdjEu8JQ17PQzjDHciHV8E/fcJ1qgWjYcpvLptp/jRJ7C75kckj7Z3maajgzwxjk2ylmhgTkd5yJiX+7ywNX/48D/Bx906TXUlEUMIN+AO19MZzfc5NwDL5DAAsUOIVbGP/OTAJIfr1yPms9NoFtOad/L3Bb8OEo2xVi2ac07yyU8bftVPEtYgH6Ox+ubtYQ74dRszk4h6Qoeuqcqo4YeWA9XO471J8y6tc+oMsf3rF8zjo69W+HsfxfBNvUzheKCym4XyS3bI0KHwe7yFC7v/qR7ahMxAgMBAAECggEBAJ7cEi3KTJxe3NbHdqj+qTyco10CjNvYFA5EPwjF0H7gSxW7ujSaECuPVeCqLwau8depMKH8zePw8TZiayJp2+YMXSHZxmqgoWTwDv6RLSms3pTuXrncITIUgrtac45samr17wrudviiI2GeOzg05yTiYPab2Q2CqFUnbb0idOnCOEWK37z2ojA9XgNDukoA+1Wpm1HqoTNNRNHZOq8ZfbxyZY3iq4nuoEDQf741kzNe4skmw21N6rC21QJ8nrCfc70C47iz5XW8lfuVNkUeJc+E595HrLBp7he5cEBWKsZ4xi+X0tlyNgg9OlLuP+8twOxl9rwP/0d4pjKnnfEa0a0CgYEA+EM7FqCFhExZHoO6/c9igbtqlIc93UNT5YVrujgmgfq0ACq6X8tWV1j+1WPcYwLqOKlgprNCoW+aT0rUTI3Nq/wFr5AkAdNClje707Ec8n5NTNUSX3i2zpdgTIKFHFEgl13BsKgb5ABosexlXU/gxpJCZctQ33tfYtZfnA5Zr3MCgYEAvbukhHBv1UcSH54UULoY1tNkFKwiiAbJIcSRV+ZLqxW9adREFLxSJOqk90B9t8CXdRVgT+7Oap0GztACQ63psqxbeKeXdHnJNL4CEl4RWcge6isI3V7kU0/yx+/miWhyYGByZ816D/QUdbbF1kU14dD79TVD171uS9IJxKTRgcsCgYAopYlFGR8DHCTzNAoniA7Owsqeas4cLevMhl2u7YaQfWV/KX++M2J9hpqigWkR5OZIRKMIaA0etVEEbnH33rev0uFzbxwWGGqsgY+FB1h/82HglHofm3oCtRIVNMFqc3XsknMl40A9wjth9hxafLuGh2fLltA05tQlMIgS2t6gNQKBgQCzRHJDeIESAR7MpO4JAGyrvfwX1DSkVdUAhNvXM49XTSk0rwzMkssCenn37AVc8ymnxNTFcZuy/D8MdVlOXSosWdHrhF4D/XXw0X7fn+XA8ObU1mh/0ULmvOllo/Qs7HT1PuuZzHmCTVpvhowS0j4A6RbHLta1JxTpqsDz/c6+VQKBgQDubC69oYbaBjxOKsQGvYUhpS9RsqZCxmg1GzLcPiUOvjWzi8fNx3JrrJ8PFOcpxs+OhRT0rlzlePfHGu/lzrSuL0sCol9enFk80rKLFAw4oXAdnTbtEjaoxA1dFTrrUIxFQkHpeH0NAkqU6BVaxbCPH22zH6/BZt2J9225lBuelQ==\n publicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt/+bR1+YqImwll81GFVSIHdMHsYqOQm0SEzUNrGjzm9e44qHtEOULv8Y3HYxLvCUNez0M4wx3Ih1fBP33CdaoFo2HKby6baf40Sewu+ZHJI+2d5mmo4M8MY5NspZoYE5HeciYl/u8sDV/+PA/wcfdOk11JRFDCDfgDtfTGc33OTcAy+QwALFDiFWxj/zkwCSH69cj5rPTaBbTmnfy9wW/DhKNsVYtmnNO8slPG37VTxLWIB+jsfrm7WEO+HUbM5OIekKHrqnKqOGHlgPVzuO9SfMurXPqDLH96xfM46OvVvh7H8XwTb1M4XigspuF8kt2yNCh8Hu8hQu7/6ke2oTMQIDAQAB\n notifyUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/alipay/notify\n returnUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/alipay/return\n signType: RSA2\n charset: utf-8\n gatewayUrl: https://openapi.alipaydev.com/gateway.do\n logPath: /opt/wfc/logs/alipay/alipay_log.txt\n maxQueryRetry: 5\n queryDuLine truncated
|
||||
INSERT INTO `config_info` VALUES (71, 'sentinel-wfc-gateway-prod', 'DEFAULT_GROUP', '[\r\n {\r\n \"resource\": \"wfc-auth\",\r\n \"count\": 500,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"wfc-system\",\r\n \"count\": 1000,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"wfc-gen\",\r\n \"count\": 200,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"wfc-job\",\r\n \"count\": 300,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n }\r\n]', 'a8b3ec396dd09d5f2ba494cc80a7afa0', '2024-12-28 19:27:43', '2024-12-28 19:27:43', NULL, '172.19.0.1', '', 'wfc-prod', '限流策略', NULL, NULL, 'json', NULL, '');
|
||||
|
||||
@@ -17,8 +17,7 @@ import org.wfc.system.api.domain.SysFile;
|
||||
* @author wfc
|
||||
*/
|
||||
@RestController
|
||||
public class SysFileController
|
||||
{
|
||||
public class SysFileController {
|
||||
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
|
||||
|
||||
@Autowired
|
||||
@@ -28,19 +27,15 @@ public class SysFileController
|
||||
* 文件上传请求
|
||||
*/
|
||||
@PostMapping("upload")
|
||||
public R<SysFile> upload(MultipartFile file)
|
||||
{
|
||||
try
|
||||
{
|
||||
public R<SysFile> upload(MultipartFile file) {
|
||||
try {
|
||||
// 上传并返回访问地址
|
||||
String url = sysFileService.uploadFile(file);
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setName(FileUtils.getName(url));
|
||||
sysFile.setUrl(url);
|
||||
return R.ok(sysFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
log.error("上传文件失败", e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
|
||||
+1
-2
@@ -44,7 +44,6 @@ public class LocalSysFileServiceImpl implements ISysFileService
|
||||
public String uploadFile(MultipartFile file) throws Exception
|
||||
{
|
||||
String name = FileUploadUtils.upload(localFilePath, file);
|
||||
String url = domain + localFilePrefix + name;
|
||||
return url;
|
||||
return domain + localFilePrefix + name;
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,7 @@ import org.wfc.common.core.utils.uuid.Seq;
|
||||
*
|
||||
* @author wfc
|
||||
*/
|
||||
public class FileUploadUtils
|
||||
{
|
||||
public class FileUploadUtils {
|
||||
/**
|
||||
* 默认大小 50M
|
||||
*/
|
||||
@@ -37,22 +36,16 @@ public class FileUploadUtils
|
||||
* 根据文件路径上传
|
||||
*
|
||||
* @param baseDir 相对应用的基目录
|
||||
* @param file 上传的文件
|
||||
* @param file 上传的文件
|
||||
* @return 文件名称
|
||||
* @throws IOException
|
||||
*/
|
||||
public static final String upload(String baseDir, MultipartFile file) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
public static final String upload(String baseDir, MultipartFile file) throws IOException {
|
||||
try {
|
||||
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
||||
}
|
||||
catch (FileException fe)
|
||||
{
|
||||
} catch (FileException fe) {
|
||||
throw new IOException(fe.getDefaultMessage(), fe);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
@@ -60,22 +53,23 @@ public class FileUploadUtils
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param baseDir 相对应用的基目录
|
||||
* @param file 上传的文件
|
||||
* @param baseDir 相对应用的基目录
|
||||
* @param file 上传的文件
|
||||
* @param allowedExtension 上传文件类型
|
||||
* @return 返回上传成功的文件名
|
||||
* @throws FileSizeLimitExceededException 如果超出最大大小
|
||||
* @throws FileSizeLimitExceededException 如果超出最大大小
|
||||
* @throws FileNameLengthLimitExceededException 文件名太长
|
||||
* @throws IOException 比如读写文件出错时
|
||||
* @throws InvalidExtensionException 文件校验异常
|
||||
* @throws IOException 比如读写文件出错时
|
||||
* @throws InvalidExtensionException 文件校验异常
|
||||
*/
|
||||
public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
|
||||
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
|
||||
InvalidExtensionException
|
||||
{
|
||||
InvalidExtensionException {
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw new IllegalArgumentException("File must not be null or empty");
|
||||
}
|
||||
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
|
||||
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
|
||||
{
|
||||
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) {
|
||||
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
|
||||
}
|
||||
|
||||
@@ -83,6 +77,12 @@ public class FileUploadUtils
|
||||
|
||||
String fileName = extractFilename(file);
|
||||
|
||||
// 确保上传目录存在
|
||||
File uploadDir = new File(baseDir);
|
||||
if (!uploadDir.exists()) {
|
||||
uploadDir.mkdirs();
|
||||
}
|
||||
|
||||
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
|
||||
file.transferTo(Paths.get(absPath));
|
||||
return getPathFileName(fileName);
|
||||
@@ -91,30 +91,23 @@ public class FileUploadUtils
|
||||
/**
|
||||
* 编码文件名
|
||||
*/
|
||||
public static final String extractFilename(MultipartFile file)
|
||||
{
|
||||
public static final String extractFilename(MultipartFile file) {
|
||||
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
|
||||
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), FileTypeUtils.getExtension(file));
|
||||
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType),
|
||||
FileTypeUtils.getExtension(file));
|
||||
}
|
||||
|
||||
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
|
||||
{
|
||||
private static final File getAbsoluteFile(String uploadDir, String fileName) {
|
||||
File desc = new File(uploadDir + File.separator + fileName);
|
||||
|
||||
if (!desc.exists())
|
||||
{
|
||||
if (!desc.getParentFile().exists())
|
||||
{
|
||||
desc.getParentFile().mkdirs();
|
||||
}
|
||||
if (!desc.exists() && !desc.getParentFile().exists()) {
|
||||
desc.getParentFile().mkdirs();
|
||||
}
|
||||
return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
|
||||
}
|
||||
|
||||
private static final String getPathFileName(String fileName) throws IOException
|
||||
{
|
||||
String pathFileName = "/" + fileName;
|
||||
return pathFileName;
|
||||
private static final String getPathFileName(String fileName) {
|
||||
return File.separator + fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,43 +115,31 @@ public class FileUploadUtils
|
||||
*
|
||||
* @param file 上传的文件
|
||||
* @throws FileSizeLimitExceededException 如果超出最大大小
|
||||
* @throws InvalidExtensionException 文件校验异常
|
||||
* @throws InvalidExtensionException 文件校验异常
|
||||
*/
|
||||
public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
|
||||
throws FileSizeLimitExceededException, InvalidExtensionException
|
||||
{
|
||||
private static final void assertAllowed(MultipartFile file, String[] allowedExtension)
|
||||
throws FileSizeLimitExceededException, InvalidExtensionException {
|
||||
long size = file.getSize();
|
||||
if (size > DEFAULT_MAX_SIZE)
|
||||
{
|
||||
if (size > DEFAULT_MAX_SIZE) {
|
||||
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
|
||||
}
|
||||
|
||||
String fileName = file.getOriginalFilename();
|
||||
String extension = FileTypeUtils.getExtension(file);
|
||||
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
|
||||
{
|
||||
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
|
||||
{
|
||||
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) {
|
||||
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) {
|
||||
throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
|
||||
fileName);
|
||||
}
|
||||
else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION)
|
||||
{
|
||||
} else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) {
|
||||
throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
|
||||
fileName);
|
||||
}
|
||||
else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION)
|
||||
{
|
||||
} else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) {
|
||||
throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
|
||||
fileName);
|
||||
}
|
||||
else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION)
|
||||
{
|
||||
} else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) {
|
||||
throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension,
|
||||
fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new InvalidExtensionException(allowedExtension, extension, fileName);
|
||||
}
|
||||
}
|
||||
@@ -167,16 +148,13 @@ public class FileUploadUtils
|
||||
/**
|
||||
* 判断MIME类型是否是允许的MIME类型
|
||||
*
|
||||
* @param extension 上传文件类型
|
||||
* @param extension 上传文件类型
|
||||
* @param allowedExtension 允许上传文件类型
|
||||
* @return true/false
|
||||
*/
|
||||
public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
|
||||
{
|
||||
for (String str : allowedExtension)
|
||||
{
|
||||
if (str.equalsIgnoreCase(extension))
|
||||
{
|
||||
private static final boolean isAllowedExtension(String extension, String[] allowedExtension) {
|
||||
for (String str : allowedExtension) {
|
||||
if (str.equalsIgnoreCase(extension)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# 本地文件上传
|
||||
file:
|
||||
domain: wfc-file:${WFC_FILE_PORT:9201}
|
||||
path: /opt/wfc/upload
|
||||
prefix: /kyc
|
||||
|
||||
# FastDFS配置
|
||||
fdfs:
|
||||
domain: http://wfc-file
|
||||
soTimeout: 3000
|
||||
connectTimeout: 2000
|
||||
trackerList: wfc-file:22122
|
||||
|
||||
# Minio配置
|
||||
minio:
|
||||
url: http://wfc-file:9000
|
||||
accessKey: minioadmin
|
||||
secretKey: minioadmin
|
||||
bucketName: test
|
||||
Reference in new issue
Block a user