From 872340e0dc6f76fe2997520d276207ff8cd6da1c Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Thu, 9 May 2019 16:13:58 +0000 Subject: [PATCH] Fix PutMetadata with S3 backend (#176) It turns out that the S3 API expects the additional `MetadataDirective: REPLACE` option in order to update metadata. If this is not provided, then metadata will simply be copied from the source object, which is not what we wanted. --- backends/s3/s3.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backends/s3/s3.go b/backends/s3/s3.go index ad040e1..e39786a 100644 --- a/backends/s3/s3.go +++ b/backends/s3/s3.go @@ -148,10 +148,11 @@ func (b S3Backend) Put(key string, r io.Reader, expiry time.Time, deleteKey stri func (b S3Backend) PutMetadata(key string, m backends.Metadata) (err error) { _, err = b.svc.CopyObject(&s3.CopyObjectInput{ - Bucket: aws.String(b.bucket), - Key: aws.String(key), - CopySource: aws.String("/" + b.bucket + "/" + key), - Metadata: mapMetadata(m), + Bucket: aws.String(b.bucket), + Key: aws.String(key), + CopySource: aws.String("/" + b.bucket + "/" + key), + Metadata: mapMetadata(m), + MetadataDirective: aws.String("REPLACE"), }) if err != nil { return