From ecf8bd1ae19e1ac2102339ba602553d57b64c997 Mon Sep 17 00:00:00 2001 From: divinity76 Date: Wed, 19 Jun 2024 12:45:55 +0200 Subject: [PATCH] AbstractBinaryInput::getRawBinary() simple complement to AbstractBinaryInput::getBase64() as usual, naming is hard, some possible names: getBinary getRawBinary getRawBinaryData getString getRawString ~ --- src/PageUtils/AbstractBinaryInput.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/PageUtils/AbstractBinaryInput.php b/src/PageUtils/AbstractBinaryInput.php index a16e4498..a7ba56f3 100644 --- a/src/PageUtils/AbstractBinaryInput.php +++ b/src/PageUtils/AbstractBinaryInput.php @@ -54,6 +54,17 @@ public function getBase64(int $timeout = null) return $response->getResultData('data'); } + /** + * Get raw binary data. + * + * @param int|null $timeout + * @return string + */ + public function getRawBinary(int $timeout = null): string + { + return base64_decode($this->getBase64($timeout), true); + } + /** * Save data to the given file. * @@ -89,7 +100,7 @@ public function saveToFile(string $path, int $timeout = 5000): void } } - $file = \fopen($path, 'w'); + $file = \fopen($path, 'wb'); \stream_filter_append($file, 'convert.base64-decode'); \fwrite($file, $response->getResultData('data')); \fclose($file);