Merge pull request #36807 from nextcloud/fix/noid/missing-cached-reference-image-mimetype

Avoid getting null mimetype when getting reference preview
This commit is contained in:
Julius Härtl 2023-02-23 11:04:09 +01:00 committed by GitHub
commit 00a7478d8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,10 +58,13 @@ class ReferenceController extends Controller {
$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);