Skip to content

Commit

Permalink
ensure fopen flags
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Apr 23, 2019
1 parent d88030d commit b9e229a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
;
2 changes: 1 addition & 1 deletion Handler/DownloadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion Storage/AbstractStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function resolveStream($obj, string $fieldName, ?string $className = null
return null;
}

return \fopen($path, 'r');
return \fopen($path, 'rb');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Storage/FlysystemStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]);
Expand Down

0 comments on commit b9e229a

Please sign in to comment.