Skip to content

Commit

Permalink
Fix PutMetadata with S3 backend (#176)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mutantmonkey authored and andreimarcu committed May 9, 2019
1 parent 8098b7e commit 872340e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions backends/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 872340e

Please sign in to comment.