From 8b24560f67684b8928abef59116afc7be375f9a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Fri, 15 May 2026 16:59:32 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20aws-sdk=20?= =?UTF-8?q?=E6=90=9E=E7=89=88=E6=9C=AC=E9=AA=8C=E8=AF=81=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E9=97=AE=E9=A2=98(=E9=80=82=E9=85=8D?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E4=BD=8E=E7=89=88=E6=9C=AC=E7=9A=84=E5=8E=82?= =?UTF-8?q?=E5=95=86=E9=81=BF=E5=85=8D=E6=8A=A5=E9=94=99)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/oss/client/DefaultOssClientImpl.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/client/DefaultOssClientImpl.java b/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/client/DefaultOssClientImpl.java index 837ec68df..3c358f49c 100644 --- a/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/client/DefaultOssClientImpl.java +++ b/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/client/DefaultOssClientImpl.java @@ -5,6 +5,8 @@ import org.dromara.common.oss.config.OssClientConfig; import org.dromara.common.oss.exception.S3StorageException; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.core.checksums.RequestChecksumCalculation; +import software.amazon.awssdk.core.checksums.ResponseChecksumValidation; import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3.S3AsyncClient; @@ -44,6 +46,10 @@ public class DefaultOssClientImpl extends AbstractOssClientImpl { // 创建 AWS 认证信息 StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, secretKey)); + S3Configuration s3Configuration = S3Configuration.builder() + .chunkedEncodingEnabled(false) + .pathStyleAccessEnabled(usePathStyleAccess) + .build(); // 创建AWS基于 Netty 的 S3 客户端 this.s3AsyncClient = S3AsyncClient.builder() @@ -51,6 +57,9 @@ public class DefaultOssClientImpl extends AbstractOssClientImpl { .endpointOverride(URI.create(endpointUrl)) .region(region) .forcePathStyle(usePathStyleAccess) + .serviceConfiguration(s3Configuration) + .requestChecksumCalculation(RequestChecksumCalculation.WHEN_REQUIRED) + .responseChecksumValidation(ResponseChecksumValidation.WHEN_REQUIRED) .httpClient( NettyNioAsyncHttpClient.builder() .connectionTimeout(Duration.ofSeconds(60)) @@ -69,13 +78,7 @@ public class DefaultOssClientImpl extends AbstractOssClientImpl { .region(region) .credentialsProvider(credentialsProvider) .endpointOverride(URI.create(domainUrl)) - .serviceConfiguration( - // 创建 S3 配置对象 - S3Configuration.builder() - .chunkedEncodingEnabled(false) - .pathStyleAccessEnabled(usePathStyleAccess) - .build() - ) + .serviceConfiguration(s3Configuration) .build(); // 创建异步调度器对象