master
parent
2edb4de421
commit
6d0149aa77
|
@ -7,6 +7,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
import com.njzscloud.common.core.ex.Exceptions;
|
import com.njzscloud.common.core.ex.Exceptions;
|
||||||
import com.njzscloud.common.core.tuple.Tuple2;
|
import com.njzscloud.common.core.tuple.Tuple2;
|
||||||
|
import com.njzscloud.common.minio.config.MinioProperties;
|
||||||
import io.minio.*;
|
import io.minio.*;
|
||||||
import io.minio.errors.*;
|
import io.minio.errors.*;
|
||||||
import io.minio.http.Method;
|
import io.minio.http.Method;
|
||||||
|
@ -36,7 +37,6 @@ public final class Minio {
|
||||||
private static final String BUCKET_NAME;
|
private static final String BUCKET_NAME;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
CLIENT = SpringUtil.getBean(MinioAsyncClient.class);
|
|
||||||
ERROR_MAP.put(ErrorResponseException.class, "文件存储服务响应失败");
|
ERROR_MAP.put(ErrorResponseException.class, "文件存储服务响应失败");
|
||||||
ERROR_MAP.put(InsufficientDataException.class, "文件读取失败");
|
ERROR_MAP.put(InsufficientDataException.class, "文件读取失败");
|
||||||
ERROR_MAP.put(InternalException.class, "文件服务器错误");
|
ERROR_MAP.put(InternalException.class, "文件服务器错误");
|
||||||
|
@ -45,7 +45,8 @@ public final class Minio {
|
||||||
ERROR_MAP.put(IOException.class, "文件读取失败");
|
ERROR_MAP.put(IOException.class, "文件读取失败");
|
||||||
ERROR_MAP.put(NoSuchAlgorithmException.class, "缺少 MD5 或 SHA-256 依赖");
|
ERROR_MAP.put(NoSuchAlgorithmException.class, "缺少 MD5 或 SHA-256 依赖");
|
||||||
ERROR_MAP.put(XmlParserException.class, "数据解析失败");
|
ERROR_MAP.put(XmlParserException.class, "数据解析失败");
|
||||||
BUCKET_NAME = SpringUtil.getBean(com.njzscloud.common.minio.config.MinioProperties.class).getBucketName();
|
CLIENT = SpringUtil.getBean(MinioAsyncClient.class);
|
||||||
|
BUCKET_NAME = SpringUtil.getBean(MinioProperties.class).getBucketName();
|
||||||
if (StrUtil.isNotBlank(BUCKET_NAME)) {
|
if (StrUtil.isNotBlank(BUCKET_NAME)) {
|
||||||
createBucket(BUCKET_NAME);
|
createBucket(BUCKET_NAME);
|
||||||
}
|
}
|
||||||
|
@ -53,9 +54,13 @@ public final class Minio {
|
||||||
|
|
||||||
public static void createBucket(String bucketName) {
|
public static void createBucket(String bucketName) {
|
||||||
Assert.notBlank(bucketName, "未指明存储位置");
|
Assert.notBlank(bucketName, "未指明存储位置");
|
||||||
boolean exists = Minio.execSync(() -> CLIENT.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()));
|
try {
|
||||||
if (exists) return;
|
boolean exists = Minio.execSync(() -> CLIENT.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()));
|
||||||
Minio.execSync(() -> CLIENT.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build()));
|
if (exists) return;
|
||||||
|
Minio.execSync(() -> CLIENT.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("存储桶创建失败", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Tuple2<String, List<String>> startMltUpload(String objectName, String contentType, int partNum) {
|
public static Tuple2<String, List<String>> startMltUpload(String objectName, String contentType, int partNum) {
|
||||||
|
@ -139,6 +144,7 @@ public final class Minio {
|
||||||
try {
|
try {
|
||||||
return fn.exec().get();
|
return fn.exec().get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("执行失败,文件服务器错误", e);
|
||||||
throw Exceptions.error(e, ERROR_MAP.getOrDefault(e.getClass(), "文件服务器错误"));
|
throw Exceptions.error(e, ERROR_MAP.getOrDefault(e.getClass(), "文件服务器错误"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,6 +153,7 @@ public final class Minio {
|
||||||
try {
|
try {
|
||||||
return fn.exec();
|
return fn.exec();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("执行失败,文件服务器错误", e);
|
||||||
throw Exceptions.error(e, ERROR_MAP.getOrDefault(e.getClass(), "文件服务器错误"));
|
throw Exceptions.error(e, ERROR_MAP.getOrDefault(e.getClass(), "文件服务器错误"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
spring:
|
spring:
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
location: /home/zsy/recycling_supervision/server/temp
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://localhost:3306/njzscloud_supervisory?characterEncoding=UTF-8&allowMultiQueries=true&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://127.0.0.1:3306/zsy_recycling_supervision?characterEncoding=UTF-8&allowMultiQueries=true&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password: root
|
password: Ch3nTx2BBJ28AiCZ
|
||||||
security:
|
|
||||||
auth-ignores:
|
redis:
|
||||||
- /index.html
|
enable: false
|
||||||
- /jquery.js
|
pubsub: false
|
||||||
- /sockjs.js
|
host: localhost
|
||||||
- /stomp.js
|
#password: redis
|
||||||
- /sockjs.js.map
|
database: 0
|
||||||
- /favicon.ico
|
port: 6379
|
||||||
# - /ws/**
|
|
||||||
|
|
||||||
mail:
|
mail:
|
||||||
# 邮件服务器
|
# 邮件服务器
|
||||||
|
@ -20,12 +22,29 @@ spring:
|
||||||
username: lzq@qq.com
|
username: lzq@qq.com
|
||||||
# 授权码
|
# 授权码
|
||||||
password: lzq
|
password: lzq
|
||||||
|
oss:
|
||||||
|
path: D:/ProJects/gov_manage/njzscloud-supervisory-svr/logs
|
||||||
|
minio:
|
||||||
|
endpoint: http://localhost:9090
|
||||||
|
access-key: minioadmin
|
||||||
|
secret-key: sdawi5nEH44wycoxOONSg
|
||||||
|
bucket-name: zsy
|
||||||
|
|
||||||
redis:
|
|
||||||
|
app:
|
||||||
|
district:
|
||||||
|
province: 320000
|
||||||
|
city: 320100
|
||||||
|
|
||||||
|
mybatis-plus:
|
||||||
|
tunnel:
|
||||||
enable: false
|
enable: false
|
||||||
pubsub: false
|
ssh:
|
||||||
host: 192.168.1.17
|
host: 139.224.54.144
|
||||||
#password: redis
|
port: 22
|
||||||
database: 0
|
user: root
|
||||||
port: 6379
|
credentials: D:/我的/再昇云/服务器秘钥/139.224.54.144_YZS_S1.pem
|
||||||
|
localPort: 33061
|
||||||
|
db:
|
||||||
|
host: localhost
|
||||||
|
port: 33061
|
||||||
|
|
Loading…
Reference in New Issue