Explorar el Código

Add correct method for hardcoded `/f/{fileid}`

Signed-off-by: Joas Schilling <coding@schilljs.com>
tags/v16.0.0beta1
Joas Schilling hace 5 años
padre
commit
5e5c5a16dc
No account linked to committer's email address
Se han modificado 1 ficheros con 14 adiciones y 2 borrados
  1. 14
    2
      apps/files/lib/Controller/ViewController.php

+ 14
- 2
apps/files/lib/Controller/ViewController.php Ver fichero

@@ -128,6 +128,18 @@ class ViewController extends Controller {
return \OC_Helper::getStorageInfo('/', $dirInfo);
}

/**
* @NoCSRFRequired
* @NoAdminRequired
*
* @param string $fileid
* @return TemplateResponse|RedirectResponse
*/
public function showFile(string $fileid = null): Response {
// This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server.
return $this->redirectToFile($fileid);
}

/**
* @NoCSRFRequired
* @NoAdminRequired
@@ -140,7 +152,7 @@ class ViewController extends Controller {
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]));
}
@@ -285,7 +297,7 @@ class ViewController extends Controller {
* @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);

Cargando…
Cancelar
Guardar