代码调整
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -44,11 +44,13 @@
|
||||
<groupId>me.tongfei</groupId>
|
||||
<artifactId>progressbar</artifactId>
|
||||
<version>${progressbar.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>${okhttp.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
@@ -60,6 +62,7 @@
|
||||
<artifactId>okhttp</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -67,6 +70,7 @@
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
<version>2.3.12.RELEASE</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.minioss.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.minioss.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minioss.config.MinIossProperties;
|
||||
import io.minio.*;
|
||||
@@ -27,14 +28,12 @@ public class MinIoUtils {
|
||||
@Resource
|
||||
private MinioClient instance;
|
||||
|
||||
private static final String SEPARATOR_DOT = ".";
|
||||
|
||||
private static final String SEPARATOR_ACROSS = "-";
|
||||
|
||||
private static final String SEPARATOR_STR = "";
|
||||
|
||||
// 存储桶名称
|
||||
private static final String chunkBucKet = "minio_bucket";
|
||||
/***
|
||||
* 存储桶默认名称
|
||||
*/
|
||||
private static final String CHUNK_BUCKET = "default_minio_bucket";
|
||||
|
||||
/**
|
||||
* 不排序
|
||||
@@ -62,7 +61,6 @@ public class MinIoUtils {
|
||||
|
||||
/**
|
||||
* 判断桶是否存在
|
||||
*
|
||||
* @param bucketName 桶名
|
||||
* @return boolean
|
||||
*/
|
||||
@@ -386,7 +384,7 @@ public class MinIoUtils {
|
||||
*/
|
||||
public List<String> createUploadChunkUrlList(String bucketName, String objectMD5, Integer chunkCount) {
|
||||
if (null == bucketName) {
|
||||
bucketName = chunkBucKet;
|
||||
bucketName = CHUNK_BUCKET;
|
||||
}
|
||||
if (null == objectMD5) {
|
||||
return null;
|
||||
@@ -413,7 +411,7 @@ public class MinIoUtils {
|
||||
*/
|
||||
public String createUploadChunkUrl(String bucketName, String objectMD5, Integer partNumber) {
|
||||
if (null == bucketName) {
|
||||
bucketName = chunkBucKet;
|
||||
bucketName = CHUNK_BUCKET;
|
||||
}
|
||||
if (null == objectMD5) {
|
||||
return null;
|
||||
@@ -432,7 +430,7 @@ public class MinIoUtils {
|
||||
*/
|
||||
public List<String> listChunkObjectNames(String bucketName, String ObjectMd5) {
|
||||
if (null == bucketName) {
|
||||
bucketName = chunkBucKet;
|
||||
bucketName = CHUNK_BUCKET;
|
||||
}
|
||||
if (null == ObjectMd5) {
|
||||
return null;
|
||||
@@ -449,7 +447,7 @@ public class MinIoUtils {
|
||||
*/
|
||||
public Map<Integer, String> mapChunkObjectNames(String bucketName, String ObjectMd5) {
|
||||
if (null == bucketName) {
|
||||
bucketName = chunkBucKet;
|
||||
bucketName = CHUNK_BUCKET;
|
||||
}
|
||||
if (null == ObjectMd5) {
|
||||
return null;
|
||||
@@ -479,7 +477,7 @@ public class MinIoUtils {
|
||||
@SneakyThrows
|
||||
public boolean composeObject(String chunkBucKetName, String composeBucketName, List<String> chunkNames, String objectName, boolean isDeleteChunkObject) {
|
||||
if (null == chunkBucKetName) {
|
||||
chunkBucKetName = chunkBucKet;
|
||||
chunkBucKetName = CHUNK_BUCKET;
|
||||
}
|
||||
List<ComposeSource> sourceObjectList = new ArrayList<>(chunkNames.size());
|
||||
for (String chunk : chunkNames) {
|
||||
@@ -512,7 +510,7 @@ public class MinIoUtils {
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean composeObject(String bucketName, List<String> chunkNames, String objectName) {
|
||||
return composeObject(chunkBucKet, bucketName, chunkNames, objectName, NOT_DELETE_CHUNK_OBJECT);
|
||||
return composeObject(CHUNK_BUCKET, bucketName, chunkNames, objectName, NOT_DELETE_CHUNK_OBJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,7 +522,7 @@ public class MinIoUtils {
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean composeObject(String bucketName, List<String> chunkNames, String objectName, boolean isDeleteChunkObject) {
|
||||
return composeObject(chunkBucKet, bucketName, chunkNames, objectName, isDeleteChunkObject);
|
||||
return composeObject(CHUNK_BUCKET, bucketName, chunkNames, objectName, isDeleteChunkObject);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,7 +534,7 @@ public class MinIoUtils {
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean composeObjectAndRemoveChunk(String bucketName, List<String> chunkNames, String objectName) {
|
||||
return composeObject(chunkBucKet, bucketName, chunkNames, objectName, DELETE_CHUNK_OBJECT);
|
||||
return composeObject(CHUNK_BUCKET, bucketName, chunkNames, objectName, DELETE_CHUNK_OBJECT);
|
||||
}
|
||||
|
||||
|
||||
@@ -547,10 +545,10 @@ public class MinIoUtils {
|
||||
*/
|
||||
public String minFileName(String originalFileName) {
|
||||
String suffix = originalFileName;
|
||||
if (originalFileName.contains(SEPARATOR_DOT)) {
|
||||
suffix = originalFileName.substring(originalFileName.lastIndexOf(SEPARATOR_DOT));
|
||||
if (originalFileName.contains(StrUtil.DOT)) {
|
||||
suffix = originalFileName.substring(originalFileName.lastIndexOf(StrUtil.DOT));
|
||||
}
|
||||
return UUID.randomUUID().toString().replace(SEPARATOR_ACROSS, SEPARATOR_STR).toUpperCase() + suffix;
|
||||
return UUID.randomUUID().toString().replace(StrUtil.DASHED, SEPARATOR_STR).toUpperCase() + suffix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user