Compare commits

...

2 Commits

Author SHA1 Message Date
疯狂的狮子Li
5e7fb88762 update 优化 去除OSS桶检测 桶不存在自然会报错无需额外检测 2024-10-31 17:59:56 +08:00
疯狂的狮子Li
d89727725b update 优化 删除无用注释 2024-10-31 15:55:28 +08:00
2 changed files with 0 additions and 24 deletions

View File

@@ -110,15 +110,12 @@ sa-token:
security:
# 排除路径
excludes:
# 静态资源
- /*.html
- /**/*.html
- /**/*.css
- /**/*.js
# 公共路径
- /favicon.ico
- /error
# swagger 文档配置
- /*/api-docs
- /*/api-docs/**

View File

@@ -21,7 +21,6 @@ import software.amazon.awssdk.services.s3.S3AsyncClient;
import software.amazon.awssdk.services.s3.S3Configuration;
import software.amazon.awssdk.services.s3.crt.S3CrtHttpConfiguration;
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.transfer.s3.S3TransferManager;
import software.amazon.awssdk.transfer.s3.model.*;
@@ -113,7 +112,6 @@ public class OssClient {
.serviceConfiguration(config)
.build();
checkBucket();
} catch (Exception e) {
if (e instanceof OssException) {
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并返回上传结果
*