Move download to documentcontroller

pull/1/head
Victor Dubiniuk 10 years ago
parent 33dfec8804
commit 45c30440b8

@ -1,30 +0,0 @@
<?php
/**
* ownCloud - Documents App
*
* @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.
*/
namespace OCA\Documents;
\OCP\JSON::checkLoggedIn();
$path = Helper::getArrayValueByKey($_GET, 'path');
if (!empty($path)){
if (\OC\Files\Filesystem::getMimeType($path) !== \OCA\Documents\Filter\Office::NATIVE_MIMETYPE){
$fileInfo = \OC\Files\Filesystem::getFileInfo($path);
$file = new File($fileInfo->getId());
$genesis = new Genesis($file);
$fullPath = $genesis->getPath();
} else {
$fullPath = '/files' . $path;
}
$download = new Download(\OCP\User::getUser(), $fullPath);
$download->sendResponse();
}
exit();

@ -28,6 +28,7 @@ $application->registerRoutes($this, array(
array('name' => 'document#serve', 'url' => 'ajax/genesis/{esId}', 'verb' => array('GET', 'HEAD')),
array('name' => 'document#rename', 'url' => 'ajax/documents/rename/{fileId}', 'verb' => 'POST'),
array('name' => 'document#listAll', 'url' => 'ajax/documents/list', 'verb' => 'GET'),
array('name' => 'document#download', 'url' => 'ajax/download.php', 'verb' => array('GET', 'HEAD')),
//settings
array('name' => 'settings#savePersonal', 'url' => 'ajax/personal.php', 'verb' => 'POST'),
array('name' => 'settings#setUnstable', 'url' => 'ajax/config/unstable', 'verb' => 'POST'),
@ -37,9 +38,6 @@ $application->registerRoutes($this, array(
/** @var $this \OC\Route\Router */
$this->create('documents_ajax_download', 'ajax/download.php')
->actionInclude('documents/ajax/download.php');
$this->create('documents_ajax_mimes', 'ajax/mimes.php')
->actionInclude('documents/ajax/mimes.php');

@ -21,6 +21,8 @@ use \OCA\Documents\Db;
use \OCA\Documents\Helper;
use \OCA\Documents\Storage;
use \OCA\Documents\Download;
use \OCA\Documents\File;
use OCA\Documents\Genesis;
class DocumentController extends Controller{
@ -86,6 +88,24 @@ class DocumentController extends Controller{
$download->sendResponse();
}
/**
* @NoAdminRequired
*/
public function download($path){
if ($path){
if (\OC\Files\Filesystem::getMimeType($path) !== \OCA\Documents\Filter\Office::NATIVE_MIMETYPE){
$fileInfo = \OC\Files\Filesystem::getFileInfo($path);
$file = new File($fileInfo->getId());
$genesis = new Genesis($file);
$fullPath = $genesis->getPath();
} else {
$fullPath = '/files' . $path;
}
$download = new Download($this->uid, $fullPath);
$download->sendResponse();
}
}
/**
* @NoAdminRequired
*/

@ -63,7 +63,8 @@ var odfViewer = {
} else {
//Public page, files app, etc
var dirName = $('#dir').val()!='/' ? $('#dir').val() + '/' : '/';
var location = OC.filePath('documents', 'ajax', 'download.php') + '?path=' + dirName + encodeURIComponent(filename);
var location = OC.filePath('documents', 'ajax', 'download.php') + '?path=' + dirName + encodeURIComponent(filename)
+ '&requesttoken=' + oc_requesttoken;
OC.addStyle('documents', '3rdparty/webodf/editor');
}

Loading…
Cancel
Save