Invalid Content-Range in multipart upload
rafaeljusto opened this issue · comments
Rafael Dantas Justo commented
We are sending the Content-Range header without the bytes
label. This is causing the error:
InvalidParameterValueException: Invalid Content-Range: 0-4194304/1554187834
Rafael Dantas Justo commented
This should solve the problem:
diff --git a/internal/cloud/aws.go b/internal/cloud/aws.go
index 58e6789..9b3b411 100644
--- a/internal/cloud/aws.go
+++ b/internal/cloud/aws.go
@@ -187,7 +187,7 @@ func (a *AWSCloud) sendBig(archive *os.File, archiveSize int64) (Backup, error)
AccountId: aws.String(a.AccountID),
Body: body,
Checksum: aws.String(hex.EncodeToString(hash.TreeHash)),
- Range: aws.String(fmt.Sprintf("%d-%d/%d", offset, offset+int64(n), archiveSize)),
+ Range: aws.String(fmt.Sprintf("bytes %d-%d/%d", offset, offset+int64(n)-1, archiveSize)),
UploadId: initiateMultipartUploadOutput.UploadId,
VaultName: aws.String(a.VaultName),
}
We need also to change the offset range (offset+int64(n)-1) to avoid the error:
InvalidParameterValueException: Content-Range: bytes 0-4194304/1554187834 is incompatible with Content-Length: 4194304
But maybe something is wrong, because the checksum from the uploaded archive doesn't match with the local TAR.
Rafael Dantas Justo commented
That's why we need to fix the offset range:
https://tools.ietf.org/html/rfc2616#section-14.16
Unlike byte-ranges-specifier values (see section 14.35.1), a byte-
range-resp-spec MUST only specify one range, and MUST contain
absolute byte positions for both the first and last byte of the
range.
Examples of byte-content-range-spec values, assuming that the entity
contains a total of 1234 bytes:
. The first 500 bytes:
bytes 0-499/1234
. The second 500 bytes:
bytes 500-999/1234
. All except for the first 500 bytes:
bytes 500-1233/1234
. The last 500 bytes:
bytes 734-1233/1234