diff --git a/.php_cs b/.php_cs index a5c691f8..d710559e 100644 --- a/.php_cs +++ b/.php_cs @@ -37,6 +37,7 @@ return PhpCsFixer\Config::create() 'ordered_imports' => true, 'declare_strict_types' => false, 'native_function_invocation' => true, + 'fopen_flags' => ['b_mode' => true], ]) ->setFinder($finder) ; diff --git a/Handler/DownloadHandler.php b/Handler/DownloadHandler.php index 1686fd00..e37bdf3e 100644 --- a/Handler/DownloadHandler.php +++ b/Handler/DownloadHandler.php @@ -75,7 +75,7 @@ public function downloadObject($object, string $field, ?string $className = null private function createDownloadResponse($stream, string $filename, ?string $mimeType = 'application/octet-stream', bool $forceDownload = true): StreamedResponse { $response = new StreamedResponse(function () use ($stream): void { - \stream_copy_to_stream($stream, \fopen('php://output', 'w')); + \stream_copy_to_stream($stream, \fopen('php://output', 'wb')); }); $disposition = $response->headers->makeDisposition( diff --git a/Storage/AbstractStorage.php b/Storage/AbstractStorage.php index 485d55de..b41ea9f6 100644 --- a/Storage/AbstractStorage.php +++ b/Storage/AbstractStorage.php @@ -108,7 +108,7 @@ public function resolveStream($obj, string $fieldName, ?string $className = null return null; } - return \fopen($path, 'r'); + return \fopen($path, 'rb'); } /** diff --git a/Storage/FlysystemStorage.php b/Storage/FlysystemStorage.php index 6a5fa263..a54ad491 100644 --- a/Storage/FlysystemStorage.php +++ b/Storage/FlysystemStorage.php @@ -34,7 +34,7 @@ protected function doUpload(PropertyMapping $mapping, UploadedFile $file, ?strin $fs = $this->getFilesystem($mapping); $path = !empty($dir) ? $dir.'/'.$name : $name; - $stream = \fopen($file->getRealPath(), 'r'); + $stream = \fopen($file->getRealPath(), 'rb'); $fs->putStream($path, $stream, [ 'mimetype' => $file->getMimeType(), ]);