Browse Source

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
pull/7183/merge
Chris Lu 1 day ago
committed by GitHub
parent
commit
b868980260
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 17
      weed/remote_storage/s3/s3_storage_client.go

17
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 {

Loading…
Cancel
Save