From 9808c2371dcaf45c44de1def4c7f7f86812dba82 Mon Sep 17 00:00:00 2001 From: Gustav Grusell Date: Mon, 13 Jan 2025 10:27:06 +0100 Subject: [PATCH] fix: disable s3 multipart upload when using anonymous access Multipart upload is not supported by the s3 sdk when using anonymous access. Signed-off-by: Gustav Grusell --- .../se/svt/oss/encore/S3RemoteFilesConfiguration.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/encore-common/src/main/kotlin/se/svt/oss/encore/S3RemoteFilesConfiguration.kt b/encore-common/src/main/kotlin/se/svt/oss/encore/S3RemoteFilesConfiguration.kt index 94eda9c..97a45a7 100644 --- a/encore-common/src/main/kotlin/se/svt/oss/encore/S3RemoteFilesConfiguration.kt +++ b/encore-common/src/main/kotlin/se/svt/oss/encore/S3RemoteFilesConfiguration.kt @@ -32,7 +32,7 @@ class S3RemoteFilesConfiguration { fun s3Client(s3Region: Region, s3Properties: S3Properties) = S3AsyncClient.builder() .region(s3Region) .crossRegionAccessEnabled(true) - .multipartEnabled(true) + .multipartEnabled(!s3Properties.anonymousAccess) // Multipart upload requires credentials .serviceConfiguration( S3Configuration.builder() .pathStyleAccessEnabled(true) @@ -71,6 +71,11 @@ class S3RemoteFilesConfiguration { fun s3UriConverter(s3Properties: S3Properties, s3Region: Region) = S3UriConverter(s3Properties, s3Region) @Bean - fun s3RemoteFileHandler(s3Client: S3AsyncClient, s3Presigner: S3Presigner, s3Properties: S3Properties, s3UriConverter: S3UriConverter) = + fun s3RemoteFileHandler( + s3Client: S3AsyncClient, + s3Presigner: S3Presigner, + s3Properties: S3Properties, + s3UriConverter: S3UriConverter + ) = S3RemoteFileHandler(s3Client, s3Presigner, s3Properties, s3UriConverter) }