diff options
-rw-r--r-- | controller/documentcontroller.php | 15 | ||||
-rw-r--r-- | lib/db/wopi.php | 12 |
2 files changed, 18 insertions, 9 deletions
diff --git a/controller/documentcontroller.php b/controller/documentcontroller.php index e42656bb..8908316c 100644 --- a/controller/documentcontroller.php +++ b/controller/documentcontroller.php @@ -379,7 +379,7 @@ class DocumentController extends Controller { return false; } - $view = new \OC\Files\View('/' . $res['user'] . '/'); + $view = new \OC\Files\View('/' . $res['user'] . '/files'); $info = $view->getFileInfo($res['path']); \OC::$server->getLogger()->debug('File info: {info}.', [ 'app' => $this->appName, 'info' => $info ]); @@ -412,7 +412,7 @@ class DocumentController extends Controller { //TODO: Support X-WOPIMaxExpectedSize header. $res = $row->getPathForToken($fileId, $token); - return new DownloadResponse($this->request, $res['user'], $res['path']); + return new DownloadResponse($this->request, $res['user'], '/files' . $res['path']); } /** @@ -431,14 +431,21 @@ class DocumentController extends Controller { $row->loadBy('token', $token); $res = $row->getPathForToken($fileId, $token); - $view = new \OC\Files\View('/' . $res['user'] . '/'); + $root = '/' . $res['user'] . '/files'; + $view = new \OC\Files\View($root); // Read the contents of the file from the POST body and store. - $content = file_get_contents('php://input'); + $content = fopen('php://input', 'r'); \OC::$server->getLogger()->debug('Putting {size} bytes.', [ 'app' => $this->appName, 'size' => strlen($content) ]); + // Setup the FS which is needed to emit hooks (versioning). + \OC_Util::tearDownFS(); + \OC_Util::setupFS($res['user'], $root); + $view->file_put_contents($res['path'], $content); + \OC_Util::tearDownFS(); + return array( 'status' => 'success' ); diff --git a/lib/db/wopi.php b/lib/db/wopi.php index 12a0aaef..cc722774 100644 --- a/lib/db/wopi.php +++ b/lib/db/wopi.php @@ -45,14 +45,16 @@ class Wopi extends \OCA\Richdocuments\Db{ $view = \OC\Files\Filesystem::getView(); // Get the virtual path (if the file is shared). $path = $view->getPath($fileId); + if (!$view->is_file($path) || !$view->isUpdatable($path)) { throw new \Exception('Invalid fileId.'); } // Figure out the real owner, if not us. $user = $view->getOwner($path); - // Create a view into the owner's FS. - $view = new \OC\Files\View('/' . $user . '/'); + + // Create a view into the owner's FS. + $view = new \OC\Files\View('/' . $user . '/files'); // Find the real path. $path = $view->getPath($fileId); if (!$view->is_file($path)) { @@ -63,8 +65,8 @@ class Wopi extends \OCA\Richdocuments\Db{ \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER . \OCP\Security\ISecureRandom::CHAR_DIGITS); - \OC::$server->getLogger()->debug('Issuing token for {user} file {fileId}: {token}', - [ 'user' => $user, 'fileId' => $fileId, 'token' => $token ]); + \OC::$server->getLogger()->debug('Issuing token for {user} file {fileId}, path {path}: {token}', + [ 'user' => $user, 'fileId' => $fileId, 'path' => $path, 'token' => $token ]); $wopi = new \OCA\Richdocuments\Db\Wopi([ $user, @@ -112,7 +114,7 @@ class Wopi extends \OCA\Richdocuments\Db{ } $user = $row['uid']; - $view = new \OC\Files\View('/' . $user . '/'); + $view = new \OC\Files\View('/' . $user . '/files'); $path = $row['path']; if (!$view->is_file($path)) { |