From 7826e39fcf7f6d4545a9f4ac365bf6ee7475e7bc Mon Sep 17 00:00:00 2001 From: Paul Kohout Date: Tue, 2 Oct 2018 23:49:02 -0400 Subject: [PATCH] s3: use configured server-side-encryption and storace class options when calling CopyObject() - fixes #2610 --- backend/s3/s3.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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)