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: Fix corrupting Content-Type on mod time update

Joseph Spurrierfe0289f2f5ea
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,