TASK:异常提示语言更换
This commit is contained in:
@@ -71,7 +71,8 @@ public class MinioUtil {
|
|||||||
return bucketName + "/" + filePath;
|
return bucketName + "/" + filePath;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("文件上传失败: {}", e.getMessage(), e);
|
log.error("文件上传失败: {}", e.getMessage(), e);
|
||||||
throw new MinioException("文件上传失败", e);
|
// throw new MinioException("文件上传失败", e);
|
||||||
|
throw new MinioException("File upload failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +112,8 @@ public class MinioUtil {
|
|||||||
return url;
|
return url;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取临时访问地址失败: {}", e.getMessage(), e);
|
log.error("获取临时访问地址失败: {}", e.getMessage(), e);
|
||||||
throw new MinioException("获取临时访问地址失败", e);
|
// throw new MinioException("获取临时访问地址失败", e);
|
||||||
|
throw new MinioException("Failed to get temporary access URL", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +125,8 @@ public class MinioUtil {
|
|||||||
try {
|
try {
|
||||||
int index = objectPath.indexOf("/");
|
int index = objectPath.indexOf("/");
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
throw new MinioException("无效的对象路径,格式应为 bucketName/filePath");
|
// throw new MinioException("无效的对象路径,格式应为 bucketName/filePath");
|
||||||
|
throw new MinioException("Invalid object path, format should be bucketName/filePath");
|
||||||
}
|
}
|
||||||
String bucketName = objectPath.substring(0, index);
|
String bucketName = objectPath.substring(0, index);
|
||||||
String filePath = objectPath.substring(index + 1);
|
String filePath = objectPath.substring(index + 1);
|
||||||
@@ -136,7 +139,8 @@ public class MinioUtil {
|
|||||||
log.info("文件删除成功,桶名: {}, 文件路径: {}", bucketName, filePath);
|
log.info("文件删除成功,桶名: {}, 文件路径: {}", bucketName, filePath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("文件删除失败: {}", e.getMessage(), e);
|
log.error("文件删除失败: {}", e.getMessage(), e);
|
||||||
throw new MinioException("文件删除失败", e);
|
// throw new MinioException("文件删除失败", e);
|
||||||
|
throw new MinioException("File deletion failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +153,8 @@ public class MinioUtil {
|
|||||||
String firstPath = objectPaths.get(0);
|
String firstPath = objectPaths.get(0);
|
||||||
int index = firstPath.indexOf("/");
|
int index = firstPath.indexOf("/");
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
throw new MinioException("无效的对象路径,格式应为 bucketName/filePath");
|
// throw new MinioException("无效的对象路径,格式应为 bucketName/filePath");
|
||||||
|
throw new MinioException("Invalid object path, format should be bucketName/filePath");
|
||||||
}
|
}
|
||||||
String bucketName = firstPath.substring(0, index);
|
String bucketName = firstPath.substring(0, index);
|
||||||
|
|
||||||
@@ -175,7 +180,8 @@ public class MinioUtil {
|
|||||||
log.info("批量删除文件成功,桶名: {}, 文件数量: {}", bucketName, objectPaths.size());
|
log.info("批量删除文件成功,桶名: {}, 文件数量: {}", bucketName, objectPaths.size());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("批量删除文件失败: {}", e.getMessage(), e);
|
log.error("批量删除文件失败: {}", e.getMessage(), e);
|
||||||
throw new MinioException("批量删除文件失败", e);
|
// throw new MinioException("批量删除文件失败", e);
|
||||||
|
throw new MinioException("Batch file deletion failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +205,8 @@ public class MinioUtil {
|
|||||||
return uploadImage(imageBytes, bucketName, filePath, contentType);
|
return uploadImage(imageBytes, bucketName, filePath, contentType);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("base64图片上传失败: {}", e.getMessage(), e);
|
log.error("base64图片上传失败: {}", e.getMessage(), e);
|
||||||
throw new MinioException("base64图片上传失败", e);
|
// throw new MinioException("base64图片上传失败", e);
|
||||||
|
throw new MinioException("Base64 image upload failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +234,8 @@ public class MinioUtil {
|
|||||||
return bucketName + "/" + filePath;
|
return bucketName + "/" + filePath;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("文件上传失败: {}", e.getMessage(), e);
|
log.error("文件上传失败: {}", e.getMessage(), e);
|
||||||
throw new MinioException("文件上传失败", e);
|
// throw new MinioException("文件上传失败", e);
|
||||||
|
throw new MinioException("File upload failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +246,8 @@ public class MinioUtil {
|
|||||||
|
|
||||||
public String uploadBytes(byte[] bytes, String objectName, String contentType, String bucketName) {
|
public String uploadBytes(byte[] bytes, String objectName, String contentType, String bucketName) {
|
||||||
if (bytes == null || bytes.length == 0) {
|
if (bytes == null || bytes.length == 0) {
|
||||||
throw new MinioException("文件内容不能为空");
|
// throw new MinioException("文件内容不能为空");
|
||||||
|
throw new MinioException("File content cannot be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -255,14 +264,16 @@ public class MinioUtil {
|
|||||||
return bucketName + "/" + objectName;
|
return bucketName + "/" + objectName;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("字节数组上传失败: {}", e.getMessage(), e);
|
log.error("字节数组上传失败: {}", e.getMessage(), e);
|
||||||
throw new MinioException("字节数组上传失败", e);
|
// throw new MinioException("字节数组上传失败", e);
|
||||||
|
throw new MinioException("Byte array upload failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream downloadFile(String logicalPath) {
|
public InputStream downloadFile(String logicalPath) {
|
||||||
int index = logicalPath.indexOf("/");
|
int index = logicalPath.indexOf("/");
|
||||||
if (index <= 0) {
|
if (index <= 0) {
|
||||||
throw new MinioException("逻辑路径格式错误,应包含桶名: " + logicalPath);
|
// throw new MinioException("逻辑路径格式错误,应包含桶名: " + logicalPath);
|
||||||
|
throw new MinioException("Invalid logical path format, should contain bucket name: " + logicalPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
String bucketName = logicalPath.substring(0, index);
|
String bucketName = logicalPath.substring(0, index);
|
||||||
@@ -271,11 +282,13 @@ public class MinioUtil {
|
|||||||
try {
|
try {
|
||||||
boolean bucketExists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
|
boolean bucketExists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
|
||||||
if (!bucketExists) {
|
if (!bucketExists) {
|
||||||
throw new MinioException("桶不存在: " + bucketName);
|
// throw new MinioException("桶不存在: " + bucketName);
|
||||||
|
throw new MinioException("Bucket does not exist: " + bucketName);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("验证桶存在性失败: {}", e.getMessage(), e);
|
log.error("验证桶存在性失败: {}", e.getMessage(), e);
|
||||||
throw new MinioException("验证桶存在性失败bucketName:{}", bucketName);
|
// throw new MinioException("验证桶存在性失败bucketName:{}", bucketName);
|
||||||
|
throw new MinioException("Failed to verify bucket existence, bucketName: " + bucketName, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -287,7 +300,8 @@ public class MinioUtil {
|
|||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("文件下载失败: {}", e.getMessage(), e);
|
log.error("文件下载失败: {}", e.getMessage(), e);
|
||||||
throw new MinioException("文件下载失败", e);
|
// throw new MinioException("文件下载失败", e);
|
||||||
|
throw new MinioException("File download failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +316,8 @@ public class MinioUtil {
|
|||||||
|
|
||||||
int firstSlashIndex = path.indexOf("/");
|
int firstSlashIndex = path.indexOf("/");
|
||||||
if (firstSlashIndex <= 0) {
|
if (firstSlashIndex <= 0) {
|
||||||
throw new MinioException("预签名URL路径格式无效,应包含桶名和对象名: " + presignedUrl);
|
// throw new MinioException("预签名URL路径格式无效,应包含桶名和对象名: " + presignedUrl);
|
||||||
|
throw new MinioException("Invalid presigned URL path format, should contain bucket name and object name: " + presignedUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
String bucketName = path.substring(0, firstSlashIndex);
|
String bucketName = path.substring(0, firstSlashIndex);
|
||||||
@@ -311,7 +326,8 @@ public class MinioUtil {
|
|||||||
return bucketName + "/" + objectName;
|
return bucketName + "/" + objectName;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("预签名URL解析失败: {}", e.getMessage(), e);
|
log.error("预签名URL解析失败: {}", e.getMessage(), e);
|
||||||
throw new MinioException("预签名URL解析失败", e);
|
// throw new MinioException("预签名URL解析失败", e);
|
||||||
|
throw new MinioException("Failed to parse presigned URL", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,14 +453,16 @@ public class MinioUtil {
|
|||||||
|
|
||||||
public String convertToLogicalPath(String url) {
|
public String convertToLogicalPath(String url) {
|
||||||
if (url == null || url.isEmpty()) {
|
if (url == null || url.isEmpty()) {
|
||||||
throw new MinioException("URL不能为空");
|
// throw new MinioException("URL不能为空");
|
||||||
|
throw new MinioException("URL cannot be empty");
|
||||||
}
|
}
|
||||||
if (isMinioLogicalPath(url)) {
|
if (isMinioLogicalPath(url)) {
|
||||||
return url.trim();
|
return url.trim();
|
||||||
} else if (isPresignedUrl(url)) {
|
} else if (isPresignedUrl(url)) {
|
||||||
return getLogicalPathFromPresignedUrl(url);
|
return getLogicalPathFromPresignedUrl(url);
|
||||||
} else {
|
} else {
|
||||||
throw new MinioException("无法识别的MinIO资源格式: " + url + ",请提供有效的预签名URL或逻辑路径");
|
// throw new MinioException("无法识别的MinIO资源格式: " + url + ",请提供有效的预签名URL或逻辑路径");
|
||||||
|
throw new MinioException("Unrecognized MinIO resource format: " + url + ", please provide a valid presigned URL or logical path");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user