Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\App\IAppManager;
use OCP\Files\Folder;
Expand Down Expand Up @@ -128,6 +129,18 @@ protected function getStorageInfo() {
return \OC_Helper::getStorageInfo('/', $dirInfo);
}

/**
* @NoCSRFRequired
* @NoAdminRequired
*
* @param string $fileid
* @return TemplateResponse|RedirectResponse
*/
public function showFile(string $fileid = null): Response {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bildschirmfoto 2019-03-14 um 16 27 07

🙈 Let me fix that.

// This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server.
return $this->redirectToFile($fileid);
}

/**
* @NoCSRFRequired
* @NoAdminRequired
Expand All @@ -140,7 +153,7 @@ protected function getStorageInfo() {
public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false) {
if ($fileid !== null) {
try {
return $this->showFile($fileid);
return $this->redirectToFile($fileid);
} catch (NotFoundException $e) {
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
}
Expand Down Expand Up @@ -285,7 +298,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
* @return RedirectResponse redirect response or not found response
* @throws \OCP\Files\NotFoundException
*/
private function showFile($fileId) {
private function redirectToFile($fileId) {
$uid = $this->userSession->getUser()->getUID();
$baseFolder = $this->rootFolder->getUserFolder($uid);
$files = $baseFolder->getById($fileId);
Expand Down