update 优化 去除桶检测 桶不存在自然会报错无需额外检测

This commit is contained in:
疯狂的狮子Li
2024-10-31 18:00:22 +08:00
parent dabf8e91b7
commit 612fed0428

View File

@@ -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并返回上传结果
*