update 优化 去除OSS桶检测 桶不存在自然会报错无需额外检测
This commit is contained in:
parent
d89727725b
commit
5e7fb88762
@ -21,7 +21,6 @@ import software.amazon.awssdk.services.s3.S3AsyncClient;
|
|||||||
import software.amazon.awssdk.services.s3.S3Configuration;
|
import software.amazon.awssdk.services.s3.S3Configuration;
|
||||||
import software.amazon.awssdk.services.s3.crt.S3CrtHttpConfiguration;
|
import software.amazon.awssdk.services.s3.crt.S3CrtHttpConfiguration;
|
||||||
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
|
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
|
||||||
import software.amazon.awssdk.services.s3.model.NoSuchBucketException;
|
|
||||||
import software.amazon.awssdk.services.s3.presigner.S3Presigner;
|
import software.amazon.awssdk.services.s3.presigner.S3Presigner;
|
||||||
import software.amazon.awssdk.transfer.s3.S3TransferManager;
|
import software.amazon.awssdk.transfer.s3.S3TransferManager;
|
||||||
import software.amazon.awssdk.transfer.s3.model.*;
|
import software.amazon.awssdk.transfer.s3.model.*;
|
||||||
@ -113,7 +112,6 @@ public class OssClient {
|
|||||||
.serviceConfiguration(config)
|
.serviceConfiguration(config)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
checkBucket();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof OssException) {
|
if (e instanceof OssException) {
|
||||||
throw e;
|
throw e;
|
||||||
@ -122,25 +120,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,并返回上传结果
|
* 上传文件到 Amazon S3,并返回上传结果
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user