Skip to content

Commit b540e7b

Browse files
committed
Fix memory bug with stream_copy_to_stream (#206)
1 parent 86437aa commit b540e7b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,10 @@ private function fileDownload(array $options) {
13611361
$file_stream = fopen($options['file'], 'rb');
13621362
$stdout_stream = fopen('php://output', 'wb');
13631363

1364-
stream_copy_to_stream($file_stream, $stdout_stream);
1364+
$buffer_size = 64 * 1024 * 1024; // 64K should be decent for a network stream
1365+
while (!feof($file_stream)) {
1366+
fwrite($stdout_stream, fread($file_stream, $buffer_size));
1367+
}
13651368

13661369
fclose($file_stream);
13671370
fclose($stdout_stream);

0 commit comments

Comments
 (0)