public function uploadPartSecurely($args = array()) { $uploadId = $args["Options"]["uploadId"]; $isLastPart = FALSE; $blocksize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); if (isset($args["LastPart"])) { $isLastPart = $args["LastPart"]; } $exists = EncryptionUtil::multipartUploadContextExists($uploadId); if (!$exists) { throw new Ks3ClientException("no such upload in cache/encryption/"); } $context = EncryptionUtil::getMultipartUploadContext($uploadId); if ($context["lastPart"]) { throw new Ks3ClientException("this upload with uploadId " . $uploadId, " has been upload last part"); } $plainTextLength = EncryptionUtil::plainTextLength($args); if ($plainTextLength <= 0) { throw new Ks3ClientException("get content length failed ,unexpected content length " . $plainTextLength); } if (!$isLastPart) { if ($plainTextLength % $blocksize != 0) { throw new Ks3ClientException("Invalid part size,part size (" . $plainTextLength . ") must be multiples of the block size " . $blocksize); } } else { $args["ObjectMeta"]["Content-Length"] = $plainTextLength + ($blocksize - $plainTextLength % $blocksize); } $readCallBack = new AESCBCStreamReadCallBack(); $readCallBack->iv = base64_decode($context["nextIv"]); $readCallBack->cek = base64_decode($context["cek"]); $readCallBack->contentLength = $plainTextLength; $readCallBack->mutipartUpload = TRUE; $readCallBack->isLastPart = $isLastPart; $args["readCallBack"] = $readCallBack; $upResult = $this->ks3client->uploadPart($args); EncryptionUtil::updateMultipartUploadContext($uploadId, $readCallBack->iv, $isLastPart); return $upResult; }