public static function updateMultipartUploadContext($UploadId, $iv, $lastPart = FALSE) { $encryptionDir = KS3_API_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR . "encryption" . DIRECTORY_SEPARATOR; $content = EncryptionUtil::getMultipartUploadContext($UploadId); $content["nextIv"] = base64_encode($iv); $content["lastPart"] = $lastPart; $json = json_encode($content); $file = EncryptionUtil::openfile($encryptionDir . $UploadId, "w"); fwrite($file, $json); fclose($file); }
public function completeMultipartUploadSecurely($args = array()) { $uploadId = $args["Options"]["uploadId"]; $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("Unable to complete an encrypted multipart upload without being told which part was the last. when upload part you can add item in args like args[\"LastPart\"]=TRUE"); } $result = $this->ks3client->completeMultipartUpload($args); if (ENCRYPTPTION_STORAGE_MODE == "InstructionFile") { $req = EncryptionUtil::createInstructionFile($args["Bucket"], $args["Key"], $context["encryptedCek"], $context["firstIv"], $context["matdesc"]); $this->ks3client->putObjectByContent($req); } EncryptionUtil::deleteMultipartUploadContext($uploadId); return $result; }