From 7ee6e3feeda334e40da912f0e31898e08b59de46 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期五, 04 八月 2023 17:28:48 +0800
Subject: [PATCH] 修复雷达引导相机为null的bug
---
ard-work/src/main/java/com/ruoyi/device/hiksdk/util/minio/MinioUtils.java | 53 +++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 41 insertions(+), 12 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/device/hiksdk/util/minio/MinioUtils.java b/ard-work/src/main/java/com/ruoyi/device/hiksdk/util/minio/MinioUtils.java
index 85f91d9..46a3ded 100644
--- a/ard-work/src/main/java/com/ruoyi/device/hiksdk/util/minio/MinioUtils.java
+++ b/ard-work/src/main/java/com/ruoyi/device/hiksdk/util/minio/MinioUtils.java
@@ -1,5 +1,6 @@
package com.ruoyi.device.hiksdk.util.minio;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.device.hiksdk.config.MinioClientSingleton;
import io.minio.*;
@@ -32,6 +33,10 @@
public static boolean exitsBucket(String bucketName) {
boolean found = false;
try {
+ if(StringUtils.isEmpty(bucketName))
+ {
+ return false;
+ }
BucketExistsArgs bucketExistsArgs = BucketExistsArgs.builder().bucket(bucketName).build();
found = MinioClientSingleton.getMinioClient().bucketExists(bucketExistsArgs);
} catch (Exception ex) {
@@ -45,6 +50,10 @@
*/
public static boolean createBucket(String bucketName) {
try {
+ if(StringUtils.isEmpty(bucketName))
+ {
+ return false;
+ }
/*鍒涘缓妗�*/
MakeBucketArgs makeBucketArgs = MakeBucketArgs.builder().bucket(bucketName).build();
MinioClientSingleton.getMinioClient().makeBucket(makeBucketArgs);
@@ -133,6 +142,10 @@
log.error("minio鐢熸垚澶辨晥url寮傚父", ex.getMessage());
}
}
+ else
+ {
+ createBucket(bucketName);
+ }
return url;
}
@@ -145,6 +158,10 @@
* @淇敼浜哄拰鍏跺畠淇℃伅
*/
public static String putObjectAndGetUrl(String bucketName, MultipartFile file) {
+ if(!exitsBucket(bucketName))
+ {
+ createBucket(bucketName);
+ }
//鍒ゆ柇鏂囦欢鏄惁涓虹┖
if (null == file || 0 == file.getSize()) {
log.error("涓婁紶minio鏂囦欢鏈嶅姟鍣ㄩ敊璇紝涓婁紶鏂囦欢涓虹┖");
@@ -197,6 +214,10 @@
* @淇敼浜哄拰鍏跺畠淇℃伅
*/
public static String putObjectAndGetUrl(String bucketName, String folder, MultipartFile file) {
+ if(!exitsBucket(bucketName))
+ {
+ createBucket(bucketName);
+ }
//鍒ゆ柇鏂囦欢鏄惁涓虹┖
if (null == file || 0 == file.getSize()) {
log.error("涓婁紶minio鏂囦欢鏈嶅姟鍣ㄩ敊璇紝涓婁紶鏂囦欢涓虹┖");
@@ -351,6 +372,10 @@
*/
public static boolean uploadObject(String bucketName, String objectName, InputStream stream, long size, String contextType) {
try {
+ if(!exitsBucket(bucketName))
+ {
+ createBucket(bucketName);
+ }
PutObjectArgs putObjectArgs = PutObjectArgs.builder()
.bucket(bucketName)
.object(objectName)
@@ -375,6 +400,10 @@
*/
public static boolean uploadObject(String bucketName, String objectName, File file, String contextType) {
try {
+ if(!exitsBucket(bucketName))
+ {
+ createBucket(bucketName);
+ }
FileInputStream fileInputStream = new FileInputStream(file);
PutObjectArgs putObjectArgs = PutObjectArgs.builder()
.bucket(bucketName)
@@ -400,13 +429,9 @@
*/
public static boolean uploadObject(String bucketName, String objectName, MultipartFile multipartFile, String contextType) {
try {
- if (bucketName.isEmpty()) {
- log.error("bucket鍚嶇О涓虹┖");
- return false;
- }
- if (objectName.isEmpty()) {
- log.error("瀵硅薄鍚嶇О涓虹┖");
- return false;
+ if(!exitsBucket(bucketName))
+ {
+ createBucket(bucketName);
}
InputStream inputStream = multipartFile.getInputStream();
PutObjectArgs putObjectArgs = PutObjectArgs.builder()
@@ -433,6 +458,10 @@
*/
public static boolean uploadObject(String bucketName, MultipartFile multipartFile, String contextType) {
try {
+ if(!exitsBucket(bucketName))
+ {
+ createBucket(bucketName);
+ }
if (multipartFile == null) {
log.error("涓婁紶鏂囦欢涓虹┖");
return false;
@@ -461,11 +490,11 @@
* @param localFilePathName
* @return
*/
- public static boolean uploadObject(String bulkName, String objectName, String localFilePathName, String contextType) {
+ public static boolean uploadObject(String bucketName, String objectName, String localFilePathName, String contextType) {
try {
- if (!exitsBucket(bulkName)) {
- log.debug(bulkName + "涓嶅瓨鍦�");
- return false;
+ if(!exitsBucket(bucketName))
+ {
+ createBucket(bucketName);
}
File file = new File(localFilePathName);
if (!file.exists()) {
@@ -473,7 +502,7 @@
return false;
}
UploadObjectArgs uploadObjectArgs = UploadObjectArgs.builder()
- .bucket(bulkName)
+ .bucket(bucketName)
.object(objectName)
.filename(localFilePathName)
.contentType(contextType)
--
Gitblit v1.9.3