getMethod() === 'POST') { return Create::promiseFor(new Response(200, [], 'upload-1' . '')); } return Create::promiseFor(new Response(200, [ 'Content-Length' => '1048576', 'ETag' => '"known-etag"', 'x-amz-version-id' => 'known-version', 'x-amz-meta-virt-sha256' => $sha256, ])); }; $client = new CloudObjectStorageS3Client(new Client([ 'handler' => HandlerStack::create($handler), ])); $config = [ 'endpoint' => 'https://objects.example.com', 'region' => 'ewr', 'bucket' => 'template-bucket', 'prefix' => 'virt-cloud', 'path_style' => true, ]; $credentials = [ 'access_key_id' => 'TEMPLATEACCESSKEY', 'secret_access_key' => 'template-secret', ]; $key = 'virt-cloud/cloud-templates/template/generation/system.qcow2'; $plan = $client->prepareKnownIdentityMultipartUpload( $config, $credentials, $key, 1048576, $sha256, 1793894400, 3600 ); $create = $requests[0] ?? null; $assert($create instanceof RequestInterface && $create->getHeaderLine('x-amz-meta-virt-sha256') === $sha256 && str_contains( $create->getHeaderLine('Authorization'), 'x-amz-meta-virt-sha256' ), 'Known multipart creation did not sign immutable SHA metadata.'); $assert(($plan['upload_id'] ?? '') === 'upload-1' && ($plan['maximum_size_bytes'] ?? 0) === 1048576, 'Known multipart upload plan was not created.'); $identity = $client->inspectObject($config, $credentials, $key); $assert(($identity['sha256'] ?? '') === $sha256 && ($identity['size_bytes'] ?? 0) === 1048576 && ($identity['version_id'] ?? '') === 'known-version', 'Known multipart HEAD did not preserve immutable identity.'); echo "Known-identity multipart publication passed.\n";