From b868980260e39d3f2efe68b1904fdb75af3a6fc6 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 15 Mar 2026 13:32:48 -0700 Subject: [PATCH] fix(remote): don't send empty StorageClass in S3 uploads (#8645) When S3StorageClass is empty (the default), aws.String("") was passed as the StorageClass in PutObject requests. While AWS S3 treats this as "use default," S3-compatible providers (e.g. SharkTech) reject it with InvalidStorageClass. Only set StorageClass when a non-empty value is configured, letting the provider use its default. Fixes #8644 --- weed/remote_storage/s3/s3_storage_client.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/weed/remote_storage/s3/s3_storage_client.go b/weed/remote_storage/s3/s3_storage_client.go index 7f82808f8..4d12998e7 100644 --- a/weed/remote_storage/s3/s3_storage_client.go +++ b/weed/remote_storage/s3/s3_storage_client.go @@ -275,13 +275,16 @@ func (s *s3RemoteStorageClient) WriteFile(loc *remote_pb.RemoteStorageLocation, } // Upload the file to S3. - _, err = uploader.Upload(&s3manager.UploadInput{ - Bucket: aws.String(loc.Bucket), - Key: aws.String(loc.Path[1:]), - Body: reader, - Tagging: awsTags, - StorageClass: aws.String(s.conf.S3StorageClass), - }) + uploadInput := &s3manager.UploadInput{ + Bucket: aws.String(loc.Bucket), + Key: aws.String(loc.Path[1:]), + Body: reader, + Tagging: awsTags, + } + if s.conf.S3StorageClass != "" { + uploadInput.StorageClass = aws.String(s.conf.S3StorageClass) + } + _, err = uploader.Upload(uploadInput) //in case it fails to upload if err != nil {