From 7f207156ecfbcc283510aecddd9eeeae0b54df65 Mon Sep 17 00:00:00 2001 From: wd256 Date: Wed, 2 May 2018 14:50:00 +1000 Subject: [PATCH] Copy an object without user-defined metadata for Azure gateway (#5872) --- cmd/gateway/azure/gateway-azure.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/gateway/azure/gateway-azure.go b/cmd/gateway/azure/gateway-azure.go index 8514b5eb0..1c46c8296 100644 --- a/cmd/gateway/azure/gateway-azure.go +++ b/cmd/gateway/azure/gateway-azure.go @@ -716,6 +716,17 @@ func (a *azureObjects) CopyObject(ctx context.Context, srcBucket, srcObject, des logger.LogIf(ctx, err) return objInfo, azureToObjectError(err, srcBucket, srcObject) } + // Azure will copy metadata from the source object when an empty metadata map is provided. + // To handle the case where the source object should be copied without its metadata, + // the metadata must be removed from the dest. object after the copy completes + if len(azureMeta) == 0 && len(destBlob.Metadata) != 0 { + destBlob.Metadata = azureMeta + err = destBlob.SetMetadata(nil) + if err != nil { + logger.LogIf(ctx, err) + return objInfo, azureToObjectError(err, srcBucket, srcObject) + } + } destBlob.Properties = props err = destBlob.SetProperties(nil) if err != nil {