[reference preview] fix getting null mimetype if the cached reference lacks an image content type

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
pull/36807/head
Julien Veyssier 1 year ago
parent 710c593d53
commit 01cefbd6d6
No known key found for this signature in database
GPG Key ID: 4141FEE162030638

@ -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);

Loading…
Cancel
Save