Skip to content

Commit

Permalink
Merge pull request #36828 from nextcloud/backport/36807/stable25
Browse files Browse the repository at this point in the history
[stable25] Avoid getting null mimetype when getting reference preview
  • Loading branch information
MichaIng authored Feb 26, 2023
2 parents 83b1b08 + 5430044 commit 78076c6
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 78076c6

Please sign in to comment.