From fe0289f2f5ea99d0e5bda1b19ba9e0a0a13045cf Mon Sep 17 00:00:00 2001 From: Joseph Spurrier Date: Sat, 2 Jan 2016 03:58:48 -0500 Subject: [PATCH] s3: Fix corrupting Content-Type on mod time update This fixes an issue where updating the modification time resets the content-type to the S3 default of binary/octet-stream which breaks static websites that expect an html file to have a content-type of text/html. --- s3/s3.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/s3/s3.go b/s3/s3.go index 99a5a310e..de2e3e416 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -644,6 +644,9 @@ func (o *Object) SetModTime(modTime time.Time) { } o.meta[metaMtime] = aws.String(swift.TimeToFloatString(modTime)) + // Guess the content type + contentType := fs.MimeType(o) + // Copy the object to itself to update the metadata key := o.fs.root + o.remote sourceKey := o.fs.bucket + "/" + key @@ -652,6 +655,7 @@ func (o *Object) SetModTime(modTime time.Time) { Bucket: &o.fs.bucket, ACL: &o.fs.perm, Key: &key, + ContentType: &contentType, CopySource: &sourceKey, Metadata: o.meta, MetadataDirective: &directive,