From b1bcc60d83866627b1b28a0eda336e0f246dbe8e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 14 Apr 2012 16:44:15 +0200 Subject: reuse OC_L10N objects --- lib/files.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/files.php') diff --git a/lib/files.php b/lib/files.php index 01558a68588..aacd2c9e004 100644 --- a/lib/files.php +++ b/lib/files.php @@ -225,7 +225,7 @@ class OC_Files { */ static function validateZipDownload($dir, $files) { if(!OC_Config::getValue('allowZipDownload', true)) { - $l = new OC_L10N('files'); + $l = OC_L10N::get('files'); header("HTTP/1.0 409 Conflict"); $tmpl = new OC_Template( '', 'error', 'user' ); $errors = array( @@ -250,7 +250,7 @@ class OC_Files { $totalsize += OC_Filesystem::filesize($dir.'/'.$files); } if($totalsize > $zipLimit) { - $l = new OC_L10N('files'); + $l = OC_L10N::get('files'); header("HTTP/1.0 409 Conflict"); $tmpl = new OC_Template( '', 'error', 'user' ); $errors = array( -- cgit v1.2.3 From 5608867edc0c4c7c9135f78800e6a199bfec7ada Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 14 Apr 2012 17:52:49 +0200 Subject: use the correct array indexes... --- lib/files.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/files.php') diff --git a/lib/files.php b/lib/files.php index aacd2c9e004..a7b83149574 100644 --- a/lib/files.php +++ b/lib/files.php @@ -104,15 +104,15 @@ class OC_Files { header('Content-Type: application/zip'); header('Content-Length: ' . filesize($filename)); }else{ - header('Content-Type: ' . OC_Filesystem::getMimeType($filename)); - header('Content-Length: ' . OC_Filesystem::filesize($filename)); + $fileData=OC_FileCache::get($filename); + header('Content-Type: ' . $fileData['mimetype']); + header('Content-Length: ' . $fileData['size']); } }elseif($zip or !OC_Filesystem::file_exists($filename)){ header("HTTP/1.0 404 Not Found"); $tmpl = new OC_Template( '', '404', 'guest' ); $tmpl->assign('file',$filename); $tmpl->printPage(); -// die('404 Not Found'); }else{ header("HTTP/1.0 403 Forbidden"); die('403 Forbidden'); -- cgit v1.2.3 From c9eaffd3363f06137fb197138d0b197679085537 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 1 May 2012 20:32:13 +0200 Subject: send downloadfile piece by piece. saves RAM and is better suited for large files. --- lib/files.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/files.php') diff --git a/lib/files.php b/lib/files.php index a7b83149574..107605fc34e 100644 --- a/lib/files.php +++ b/lib/files.php @@ -119,7 +119,14 @@ class OC_Files { } @ob_end_clean(); if($zip){ - readfile($filename); + $handle=fopen($filename,'r'); + if ($handle) { + $chunkSize = 8*1024;// 1 MB chunks + while (!feof($handle)) { + echo fread($handle, $chunkSize); + flush(); + } + } unlink($filename); }else{ OC_Filesystem::readfile($filename); -- cgit v1.2.3