Skip to content

Commit

Permalink
Work around file size issues at 32 Bit systems
Browse files Browse the repository at this point in the history
Replace stream_copy_to_stream with a chunked process, to handle file sizes hat do not fit into an integer.
Implementation according to http://php.net/manual/en/function.stream-copy-to-stream.php#98119, proposed and implemented by https://github.com/rikmeijer in nextcloud/server#1707 (comment).
  • Loading branch information
derkostka authored Apr 9, 2017
1 parent 5f7bd40 commit 7d87ae2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Sapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ static function sendResponse(ResponseInterface $response) {
if ($contentLength !== null) {
$output = fopen('php://output', 'wb');
if (is_resource($body) && get_resource_type($body) == 'stream') {
stream_copy_to_stream($body, $output, (int)$contentLength);
while (!feof($body)) {
fwrite($output,fread($body,8192));
}
} else {
fwrite($output, $body, (int)$contentLength);
}
Expand Down

0 comments on commit 7d87ae2

Please sign in to comment.