diff --git a/lib/download/range.php b/lib/download/range.php index 3992fd6d..942a2ad3 100644 --- a/lib/download/range.php +++ b/lib/download/range.php @@ -20,23 +20,15 @@ class Range extends \OCA\Office\Download { $ranges = explode(',', substr($_SERVER['HTTP_RANGE'], 6)); foreach ($ranges as $range){ $parts = explode('-', $range); - if (isset($parts[0])){ - $start = $parts[0]; - } else { - $start = 0; - } - if (isset($parts[1])){ - $end = $parts[1]; - } else { - $end = $this->getFilesize() - 1; - } + $start = isset($parts[0]) ? $parts[0] : 0; + $end = isset($parts[1]) ? $parts[1] : $this->getFilesize() - 1; if ($start > $end){ $this->sendNotSatisfiable(); } - $handle = \OC\Files\Filesystem::fopen($this->filepath, 'r'); + $handle = \OC\Files\Filesystem::fopen($this->filepath, 'rb'); \fseek($handle, $start); $buffer = \fread($handle, $end - $start); $md5Sum = md5($buffer); @@ -49,6 +41,7 @@ class Range extends \OCA\Office\Download { header("Connection: close"); header("Content-type: " . $this->getMimeType()); header('Content-Disposition: attachment; filename=' . $this->getFilename()); + \OC_Util::obEnd(); echo $buffer; flush(); } diff --git a/lib/download/simple.php b/lib/download/simple.php index 6e5a0ea3..2c30e81f 100644 --- a/lib/download/simple.php +++ b/lib/download/simple.php @@ -25,7 +25,6 @@ class Simple extends \OCA\Office\Download { \OC_Util::obEnd(); \OC\Files\Filesystem::readfile($this->filepath); - exit(); } }