From 054a76a56987ddfe7471ceedcf51244ad7a3f924 Mon Sep 17 00:00:00 2001 From: Justin James Date: Fri, 4 Dec 2020 22:44:24 -0500 Subject: [PATCH] Only send x-amz-metadata-directive on CopyObject Fixes bji/libs3#80 See: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html and https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html --- src/request.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/request.c b/src/request.c index dd66863..098105f 100644 --- a/src/request.c +++ b/src/request.c @@ -405,9 +405,12 @@ static S3Status compose_amz_headers(const RequestParams *params, params->startByte, params->startByte + params->byteCount); append_amz_header(values, 0, "x-amz-copy-source-range", byteRange); } - // And the x-amz-metadata-directive header - if (properties) { - append_amz_header(values, 0, "x-amz-metadata-directive", "REPLACE"); + else { + // Add the x-amz-metadata-directive header + // Only for CopyObject, not UploadPartCopy (above) + if (properties) { + append_amz_header(values, 0, "x-amz-metadata-directive", "REPLACE"); + } } }