diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2016-07-18 13:40:59 +0300 |
---|---|---|
committer | Pranav Kant <pranavk@collabora.co.uk> | 2016-07-18 13:47:44 +0300 |
commit | 45d76a1c6855b56ed226d6ae08b4bd82291a3678 (patch) | |
tree | 99a3592c0212536c605bba4f53e6ce421392d1d3 | |
parent | e906c47ef5204882bf1ad9931a7c6d38ad6ef47a (diff) |
Add support for opening and editing files from external storage
-rw-r--r-- | controller/documentcontroller.php | 21 | ||||
-rw-r--r-- | lib/db/wopi.php | 11 |
2 files changed, 16 insertions, 16 deletions
diff --git a/controller/documentcontroller.php b/controller/documentcontroller.php index 56167e8c..d03bf9ae 100644 --- a/controller/documentcontroller.php +++ b/controller/documentcontroller.php @@ -423,17 +423,23 @@ class DocumentController extends Controller { return false; } + // Login the user to see his mount locations + $this->loginUser($res['owner']); + $view = new \OC\Files\View('/' . $res['owner'] . '/files'); $info = $view->getFileInfo($res['path']); - \OC::$server->getLogger()->debug('File info: {info}.', [ 'app' => $this->appName, 'info' => $info ]); - - $baseFileName = $info['name']; - $size = $info['size']; + // Close the session created for user login + \OC::$server->getSession()->close(); + if (!$info) { + http_response_code(404); + return false; + } + \OC::$server->getLogger()->debug('File info: {info}.', [ 'app' => $this->appName, 'info' => $info ]); return array( - 'BaseFileName' => $baseFileName, - 'Size' => $size, + 'BaseFileName' => $info['name'], + 'Size' => $info['size'], 'Version' => $version //'DownloadUrl' => '', //'FileUrl' => '', @@ -465,6 +471,9 @@ class DocumentController extends Controller { //TODO: Support X-WOPIMaxExpectedSize header. $res = $row->getPathForToken($fileId, $version, $token); + // Login the user to see his mount locations + $this->loginUser($res['owner']); + // If some previous version is requested, fetch it from Files_Version app if ($version !== '0') { \OCP\JSON::checkAppEnabled('files_versions'); diff --git a/lib/db/wopi.php b/lib/db/wopi.php index 423e5038..c8b96d0f 100644 --- a/lib/db/wopi.php +++ b/lib/db/wopi.php @@ -120,15 +120,6 @@ class Wopi extends \OCA\Richdocuments\Db{ return false; } - $owner = $row['owner_uid']; - $view = new \OC\Files\View('/' . $owner . '/files'); - $path = $row['path']; - - if (!$view->is_file($path)) { - throw new \Exception('Invalid file path.'); - } - - $editor = $row['editor_uid']; - return array('owner' => $owner, 'editor' => $editor, 'path' => $path); + return array('owner' => $row['owner_uid'], 'editor' => $row['editor_uid'], 'path' => $row['path']); } } |