mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-10-14 06:00:23 +00:00
update 优化 去除桶检测 桶不存在自然会报错无需额外检测
This commit is contained in:
@@ -113,7 +113,6 @@ public class OssClient {
|
||||
.serviceConfiguration(config)
|
||||
.build();
|
||||
|
||||
checkBucket();
|
||||
} catch (Exception e) {
|
||||
if (e instanceof OssException) {
|
||||
throw e;
|
||||
@@ -122,25 +121,6 @@ public class OssClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查桶是否存在
|
||||
*
|
||||
* @throws OssException 当创建存储桶时发生异常时抛出
|
||||
*/
|
||||
public void checkBucket() {
|
||||
String bucketName = properties.getBucketName();
|
||||
try {
|
||||
// 尝试获取存储桶的信息
|
||||
client.headBucket(x -> x.bucket(bucketName).build()).join();
|
||||
} catch (Exception ex) {
|
||||
if (ex.getCause() instanceof NoSuchBucketException) {
|
||||
throw new OssException("Bucket桶是不存在的,请核对配置信息:[" + ex.getMessage() + "]");
|
||||
} else {
|
||||
throw new OssException("判断Bucket是否存在失败,请核对配置信息:[" + ex.getMessage() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到 Amazon S3,并返回上传结果
|
||||
*
|
||||
|
Reference in New Issue
Block a user