$config['region'], 'schema'=>'https', 'credentials'=>['secretId'=>$config['secretId'], 'secretKey'=>$config['secretKey']]]); $key = 'cert/u999999999/codex-test-' . bin2hex(random_bytes(12)) . '.png'; $bytes = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+cZ7kAAAAASUVORK5CYII='); try { $client->putObject(['Bucket'=>$config['bucket'], 'Key'=>$key, 'Body'=>$bytes]); $result = \app\common\library\EnterpriseLicenseImage::read(['storage'=>'cos', 'url'=>'/' . $key, 'filesize'=>strlen($bytes)]); if (!hash_equals(hash('sha256', $bytes), hash('sha256', $result))) throw new \RuntimeException('COS image content mismatch'); echo "COS enterprise image integration passed\n"; } finally { $client->deleteObject(['Bucket'=>$config['bucket'], 'Key'=>$key]); }