51 lines
1.2 KiB
PHP
Raw Normal View History

2013-07-19 18:52:33 +03:00
<?php
2013-08-08 00:22:21 +03:00
/**
2013-08-28 12:02:27 +02:00
* ownCloud - Documents App
2013-08-08 00:22:21 +03:00
*
* @author Victor Dubiniuk
* @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/
2013-07-19 18:52:33 +03:00
2013-09-07 20:05:35 +03:00
namespace OCA\Documents;
2013-07-19 18:52:33 +03:00
2013-09-26 22:55:17 +03:00
/**
* Class processing complete download
*/
2013-09-07 20:05:35 +03:00
class Download_Simple extends \OCA\Documents\Download {
2013-08-16 18:54:31 +03:00
public function __construct($owner, $filepath){
$this->view = $this->getView($owner);
2013-07-19 18:52:33 +03:00
$this->filepath = $filepath;
}
2013-08-16 18:54:31 +03:00
/**
* Send the whole file content as a response
*/
2013-07-19 18:52:33 +03:00
public function sendResponse(){
2014-01-04 00:24:59 +03:00
$mimetype = $this->getMimeType();
$content = $this->view->file_get_contents($this->filepath);
$data = Filter::read($content, $mimetype);
header( 'Content-Type:' . $data['mimetype'] );
2013-07-19 18:52:33 +03:00
$encodedName = rawurlencode($this->getFilename());
if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])){
header(
'Content-Disposition: attachment; filepath="' . $encodedName . '"'
);
} else {
header('Content-Disposition: attachment; filepath*=UTF-8\'\'' . $encodedName
. '; filepath="' . $encodedName . '"');
}
2014-01-04 00:24:59 +03:00
header('Content-Length: ' . strlen($data['content']));
2013-07-19 18:52:33 +03:00
\OC_Util::obEnd();
2014-01-04 00:24:59 +03:00
echo $data['content'];
2013-07-19 18:52:33 +03:00
}
}