Problem description
For a multipart upload that uses client-side encryption, the total size of all parts does not match the total data size specified in the InitiateMultipartUpload request.
Causes
In a client-side encryption scenario, the size of the data uploaded in the last UploadPart request is not the expected size.
For client-side encryption, the InitiateMultipartUpload request must include the x-oss-meta-client-side-encryption-data-size and x-oss-meta-client-side-encryption-part-size headers. The size of each uploaded part, except for the last one, must match the value of x-oss-meta-client-side-encryption-part-size. The size of the last part must be the value of x-oss-meta-client-side-encryption-data-size minus the sum of the sizes of all previously uploaded parts.
Examples
For example, you send an InitiateMultipartUpload request:
POST /multipart.data?uploads HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Wed, 22 Feb 2012 08:32:21 GMT
x-oss-storage-class: Archive
Authorization: OSS qn6q**************:77Dv****************
x-oss-meta-client-side-encryption-data-size: 2048
x-oss-meta-client-side-encryption-part-size: 1024Then, you send an UploadPart request:
PUT /multipart.data?partNumber=1&uploadId=0004B9895DBBB6EC9**** HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Content-Length: 1024
Date: Wed, 22 Feb 2012 08:32:21 GMT
Authorization: OSS qn6q**************:77Dv****************
x-oss-meta-client-side-encryption-part-size: 1024
[1024 bytes data]You send a second UploadPart request:
PUT /multipart.data?partNumber=2&uploadId=0004B9895DBBB6EC9**** HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Content-Length: 100
Date: Wed, 22 Feb 2012 08:32:21 GMT
Authorization: OSS qn6q**************:77Dv****************
x-oss-meta-client-side-encryption-part-size: 1024
[100 bytes data]The upload failed due to an unexpected data size.
Solutions
Ensure that the size of the last part equals the total data size specified in the InitiateMultipartUpload request minus the sum of the sizes of all previously uploaded parts.