Merge pull request #68 from Ashod/master
Support for file versioning in WOPI
This commit is contained in:
commit
77e0908a68
@ -379,7 +379,7 @@ class DocumentController extends Controller {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = new \OC\Files\View('/' . $res['user'] . '/');
|
$view = new \OC\Files\View('/' . $res['user'] . '/files');
|
||||||
$info = $view->getFileInfo($res['path']);
|
$info = $view->getFileInfo($res['path']);
|
||||||
|
|
||||||
\OC::$server->getLogger()->debug('File info: {info}.', [ 'app' => $this->appName, 'info' => $info ]);
|
\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.
|
//TODO: Support X-WOPIMaxExpectedSize header.
|
||||||
$res = $row->getPathForToken($fileId, $token);
|
$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);
|
$row->loadBy('token', $token);
|
||||||
|
|
||||||
$res = $row->getPathForToken($fileId, $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.
|
// 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) ]);
|
\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);
|
$view->file_put_contents($res['path'], $content);
|
||||||
|
|
||||||
|
\OC_Util::tearDownFS();
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'status' => 'success'
|
'status' => 'success'
|
||||||
);
|
);
|
||||||
|
@ -45,14 +45,16 @@ class Wopi extends \OCA\Richdocuments\Db{
|
|||||||
$view = \OC\Files\Filesystem::getView();
|
$view = \OC\Files\Filesystem::getView();
|
||||||
// Get the virtual path (if the file is shared).
|
// Get the virtual path (if the file is shared).
|
||||||
$path = $view->getPath($fileId);
|
$path = $view->getPath($fileId);
|
||||||
|
|
||||||
if (!$view->is_file($path) || !$view->isUpdatable($path)) {
|
if (!$view->is_file($path) || !$view->isUpdatable($path)) {
|
||||||
throw new \Exception('Invalid fileId.');
|
throw new \Exception('Invalid fileId.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out the real owner, if not us.
|
// Figure out the real owner, if not us.
|
||||||
$user = $view->getOwner($path);
|
$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.
|
// Find the real path.
|
||||||
$path = $view->getPath($fileId);
|
$path = $view->getPath($fileId);
|
||||||
if (!$view->is_file($path)) {
|
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_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
|
||||||
\OCP\Security\ISecureRandom::CHAR_DIGITS);
|
\OCP\Security\ISecureRandom::CHAR_DIGITS);
|
||||||
|
|
||||||
\OC::$server->getLogger()->debug('Issuing token for {user} file {fileId}: {token}',
|
\OC::$server->getLogger()->debug('Issuing token for {user} file {fileId}, path {path}: {token}',
|
||||||
[ 'user' => $user, 'fileId' => $fileId, 'token' => $token ]);
|
[ 'user' => $user, 'fileId' => $fileId, 'path' => $path, 'token' => $token ]);
|
||||||
|
|
||||||
$wopi = new \OCA\Richdocuments\Db\Wopi([
|
$wopi = new \OCA\Richdocuments\Db\Wopi([
|
||||||
$user,
|
$user,
|
||||||
@ -112,7 +114,7 @@ class Wopi extends \OCA\Richdocuments\Db{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user = $row['uid'];
|
$user = $row['uid'];
|
||||||
$view = new \OC\Files\View('/' . $user . '/');
|
$view = new \OC\Files\View('/' . $user . '/files');
|
||||||
$path = $row['path'];
|
$path = $row['path'];
|
||||||
|
|
||||||
if (!$view->is_file($path)) {
|
if (!$view->is_file($path)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user