diff --git a/lib/Controller/APIv2Controller.php b/lib/Controller/APIv2Controller.php index 31c14601d..0591b3528 100644 --- a/lib/Controller/APIv2Controller.php +++ b/lib/Controller/APIv2Controller.php @@ -373,15 +373,19 @@ protected function getPreview(string $owner, int $fileId, string $filePath): arr } else { $this->view->chroot('/' . $owner . '/files'); $fileInfo = $this->view->getFileInfo($info['path']); - if (!$fileInfo instanceof FileInfo) { + if (!($fileInfo instanceof FileInfo)) { $preview = $this->getPreviewFromPath($fileId, $filePath, $info); } elseif ($this->preview->isAvailable($fileInfo)) { - $preview['source'] = $this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreview', [ - 'file' => $info['path'], - 'c' => $this->view->getETag($info['path']), - 'x' => 150, - 'y' => 150, - ]); + $params = [ + 'forceIcon' => 0, + 'a' => 0, + 'x' => 250, + 'y' => 250, + 'fileId' => $fileId, + 'c' => $fileInfo->getEtag() + ]; + + $preview['source'] = $this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreviewByFileId', $params); $preview['mimeType'] = $fileInfo->getMimetype() ?: 'application/octet-stream'; $preview['isMimeTypeIcon'] = false; } else { diff --git a/tests/Controller/APIv2ControllerTest.php b/tests/Controller/APIv2ControllerTest.php index 17b9a9b47..fac88ab60 100644 --- a/tests/Controller/APIv2ControllerTest.php +++ b/tests/Controller/APIv2ControllerTest.php @@ -733,7 +733,7 @@ public function testGetPreview(string $author, int $fileId, string $path, string $this->urlGenerator->expects($this->once()) ->method('linkToRouteAbsolute') - ->with('core.Preview.getPreview', $this->anything()) + ->with('core.Preview.getPreviewByFileId', $this->anything()) ->willReturnCallback(function () use ($returnedPath) { return '/preview' . $returnedPath; });