diff --git a/src/PageUtils/AbstractBinaryInput.php b/src/PageUtils/AbstractBinaryInput.php index a16e449..a7ba56f 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);