Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

s3: use configured server-side-encryption and storace class options when calling CopyObject() - fixes #2610

Paul Kohout7826e39fcf7f
diff --git a/backend/s3/s3.go b/backend/s3/s3.go
index 020c3e4b8..b7af0255f 100644
--- a/backend/s3/s3.go
+++ b/backend/s3/s3.go
@@ -1240,6 +1240,15 @@ func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) {
CopySource: &source,
MetadataDirective: aws.String(s3.MetadataDirectiveCopy),
}
+ if f.opt.ServerSideEncryption != "" {
+ req.ServerSideEncryption = &f.opt.ServerSideEncryption
+ }
+ if f.opt.SSEKMSKeyID != "" {
+ req.SSEKMSKeyId = &f.opt.SSEKMSKeyID
+ }
+ if f.opt.StorageClass != "" {
+ req.StorageClass = &f.opt.StorageClass
+ }
err = f.pacer.Call(func() (bool, error) {
_, err = f.c.CopyObject(&req)
return shouldRetry(err)
@@ -1409,6 +1418,15 @@ func (o *Object) SetModTime(modTime time.Time) error {
Metadata: o.meta,
MetadataDirective: &directive,
}
+ if o.fs.opt.ServerSideEncryption != "" {
+ req.ServerSideEncryption = &o.fs.opt.ServerSideEncryption
+ }
+ if o.fs.opt.SSEKMSKeyID != "" {
+ req.SSEKMSKeyId = &o.fs.opt.SSEKMSKeyID
+ }
+ if o.fs.opt.StorageClass != "" {
+ req.StorageClass = &o.fs.opt.StorageClass
+ }
err = o.fs.pacer.Call(func() (bool, error) {
_, err := o.fs.c.CopyObject(&req)
return shouldRetry(err)