diff --git a/command/cp.go b/command/cp.go index acee99c29..775e31100 100644 --- a/command/cp.go +++ b/command/cp.go @@ -690,11 +690,17 @@ func (c Copy) doUpload(ctx context.Context, srcurl *url.URL, dsturl *url.URL, ex return err } - metadata := storage.Metadata{UserDefined: extradata} - metadata.ACL = c.acl - metadata.CacheControl = c.cacheControl - metadata.Expires = c.expires - metadata.StorageClass = string(c.storageClass) + metadata := storage.Metadata{ + UserDefined: extradata, + ACL: c.acl, + CacheControl: c.cacheControl, + Expires: c.expires, + StorageClass: string(c.storageClass), + ContentEncoding: c.contentEncoding, + ContentDisposition: c.contentDisposition, + EncryptionMethod: c.encryptionMethod, + EncryptionKeyID: c.encryptionKeyID, + } if c.contentType != "" { metadata.ContentType = c.contentType @@ -702,11 +708,6 @@ func (c Copy) doUpload(ctx context.Context, srcurl *url.URL, dsturl *url.URL, ex metadata.ContentType = guessContentType(file) } - metadata.ContentEncoding = c.contentEncoding - metadata.ContentDisposition = c.contentDisposition - metadata.EncryptionMethod = c.encryptionMethod - metadata.EncryptionKeyID = c.encryptionKeyID - reader := newCountingReaderWriter(file, c.progressbar) err = dstClient.Put(ctx, reader, dsturl, metadata, c.concurrency, c.partSize) @@ -753,16 +754,18 @@ func (c Copy) doCopy(ctx context.Context, srcurl, dsturl *url.URL, extradata map return err } - metadata := storage.Metadata{UserDefined: extradata} - metadata.ACL = c.acl - metadata.CacheControl = c.cacheControl - metadata.Expires = c.expires - metadata.StorageClass = string(c.storageClass) - metadata.ContentType = c.contentType - metadata.ContentEncoding = c.contentEncoding - metadata.ContentDisposition = c.contentDisposition - metadata.EncryptionMethod = c.encryptionMethod - metadata.EncryptionKeyID = c.encryptionKeyID + metadata := storage.Metadata{ + UserDefined: extradata, + ACL: c.acl, + CacheControl: c.cacheControl, + Expires: c.expires, + StorageClass: string(c.storageClass), + ContentType: c.contentType, + ContentEncoding: c.contentEncoding, + ContentDisposition: c.contentDisposition, + EncryptionMethod: c.encryptionMethod, + EncryptionKeyID: c.encryptionKeyID, + } err = c.shouldOverride(ctx, srcurl, dsturl) if err != nil { diff --git a/command/pipe.go b/command/pipe.go index 8c968e486..77793f7bc 100644 --- a/command/pipe.go +++ b/command/pipe.go @@ -221,20 +221,23 @@ func (c Pipe) Run(ctx context.Context) error { return err } - metadata := storage.Metadata{UserDefined: c.metadata} - metadata.ACL = c.acl - metadata.CacheControl = c.cacheControl - metadata.Expires = c.expires - metadata.StorageClass = string(c.storageClass) + metadata := storage.Metadata{ + UserDefined: c.metadata, + ACL: c.acl, + CacheControl: c.cacheControl, + Expires: c.expires, + StorageClass: string(c.storageClass), + ContentEncoding: c.contentEncoding, + ContentDisposition: c.contentDisposition, + EncryptionMethod: c.encryptionMethod, + EncryptionKeyID: c.encryptionKeyID, + } + if c.contentType != "" { metadata.ContentType = c.contentType } else { metadata.ContentType = guessContentTypeByExtension(c.dst) } - metadata.ContentEncoding = c.contentEncoding - metadata.ContentDisposition = c.contentDisposition - metadata.EncryptionMethod = c.encryptionMethod - metadata.EncryptionKeyID = c.encryptionKeyID err = client.Put(ctx, &stdin{file: os.Stdin}, c.dst, metadata, c.concurrency, c.partSize) if err != nil {