diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-02-26 03:54:21 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-02-26 03:54:21 +0100 |
commit | c8c3b8a63ea1c4763e1a5197487f0ae3506339c1 (patch) | |
tree | 681345340a80215eb1e26403f2605d01536fd1bb /lib/filesystemview.php | |
parent | 0b19af5e10ea83400e114c8b2d4252fb8d50cc33 (diff) | |
download | nextcloud-server-c8c3b8a63ea1c4763e1a5197487f0ae3506339c1.tar.gz nextcloud-server-c8c3b8a63ea1c4763e1a5197487f0ae3506339c1.zip |
chunked implementation for readfile
prevents memory issues when downloading large files
Diffstat (limited to 'lib/filesystemview.php')
-rw-r--r-- | lib/filesystemview.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 91c6cd17720..ab254cc512f 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -136,7 +136,14 @@ class OC_FilesystemView { return $this->basicOperation('filesize',$path); } public function readfile($path){ - return $this->basicOperation('readfile',$path,array('read')); + $handle=$this->fopen($path,'r'); + $chunkSize = 1024*1024;// 1 MB chunks + while (!feof($handle)) { + echo fread($handle, $chunkSize); + @ob_flush(); + flush(); + } + return $this->filesize($path); } public function is_readable($path){ return $this->basicOperation('is_readable',$path); |