Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 11 additions & 7 deletions lib/Controller/APIv2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/APIv2ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down