Skip to content

Commit

Permalink
[reference preview] fix getting null mimetype if the cached reference…
Browse files Browse the repository at this point in the history
… lacks an image content type

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
  • Loading branch information
julien-nc authored and backportbot-nextcloud[bot] committed Feb 23, 2023
1 parent 0c86714 commit 5430044
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/Controller/ReferenceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ public function preview(string $referenceId): Response {
$appData = $this->appDataFactory->get('core');
$folder = $appData->getFolder('opengraph');
$file = $folder->getFile($referenceId);
$contentType = $reference === null || $reference->getImageContentType() === null
? $file->getMimeType()
: $reference->getImageContentType();
$response = new DataDownloadResponse(
$file->getContent(),
$referenceId,
$reference === null ? $file->getMimeType() : $reference->getImageContentType()
$contentType
);
} catch (NotFoundException|NotPermittedException $e) {
$response = new DataResponse('', Http::STATUS_NOT_FOUND);
Expand Down

0 comments on commit 5430044

Please sign in to comment.