libs3
libs3 copied to clipboard
Multipart Copy
Is the Multipart Copy working? I'm getting the following response when I try to copy a 6 GB file from a bucket to another:
ERROR: ErrorInvalidArgument Message: The specified header is not valid in this context Extra Details: ArgumentName: x-amz-metadata-directive ArgumentValue: REPLACE RequestId: B9A7B3C41FB12F55 HostId: oTuaiCPM5pCw99BQ1RDzSMjSTRUXhCGKgkYvwa6KrhmGp8yM8l70+9UwvXXbH2RN9cilgPyHPRE=
I am also getting the same error when trying this. In my case the source and destination were in the same bucket.
I believe the fix should be to not add this if we are doing an UploadPartCopy but only if we are doing a CopyObject.
See:
https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html
vs
https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html
https://github.com/bji/libs3/blob/287e4bee6fd430ffb52604049de80a27a77ff6b4/src/request.c#L392-L412
I believe it should be:
if (params->httpRequestType == HttpRequestTypeCOPY) {
// Add the x-amz-copy-source header
if (params->copySourceBucketName && params->copySourceBucketName[0]
&& params->copySourceKey && params->copySourceKey[0]) {
char bucketKey[S3_MAX_METADATA_SIZE];
snprintf(bucketKey, sizeof(bucketKey), "/%s/%s",
params->copySourceBucketName, params->copySourceKey);
append_amz_header(values, 0, "x-amz-copy-source", bucketKey);
}
// If byteCount != 0 then we're just copying a range, add header
if (params->byteCount > 0) {
char byteRange[S3_MAX_METADATA_SIZE];
snprintf(byteRange, sizeof(byteRange), "bytes=%zd-%zd",
params->startByte, params->startByte + params->byteCount - 1);
append_amz_header(values, 0, "x-amz-copy-source-range", byteRange);
} else {
// And the x-amz-metadata-directive header
if (properties) {
append_amz_header(values, 0, "x-amz-metadata-directive", "REPLACE");
}
}
}