aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJulien Veyssier <eneiluj@posteo.net>2022-10-06 12:57:38 +0200
committerJulien Veyssier <julien-nc@posteo.net>2022-10-13 15:18:21 +0200
commit6e03d99ab8ee4510ea44cf54f6d157e81da6e57c (patch)
treeb8b9a2f12adf8a7d6c03909431e99af5c986e688 /core
parentcdb81f76cec7c147721bdc8980778999534817dd (diff)
downloadnextcloud-server-6e03d99ab8ee4510ea44cf54f6d157e81da6e57c.tar.gz
nextcloud-server-6e03d99ab8ee4510ea44cf54f6d157e81da6e57c.zip
fix reference preview endpoint when no server-side cache configured
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Diffstat (limited to 'core')
-rw-r--r--core/Controller/ReferenceController.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/Controller/ReferenceController.php b/core/Controller/ReferenceController.php
index 591d84f3e7c..a892de03e79 100644
--- a/core/Controller/ReferenceController.php
+++ b/core/Controller/ReferenceController.php
@@ -48,18 +48,21 @@ class ReferenceController extends Controller {
/**
* @PublicPage
* @NoCSRFRequired
+ * @param string $referenceId the reference cache key
+ * @return Response
*/
public function preview(string $referenceId): Response {
$reference = $this->referenceManager->getReferenceByCacheKey($referenceId);
- if ($reference === null) {
- return new DataResponse('', Http::STATUS_NOT_FOUND);
- }
try {
$appData = $this->appDataFactory->get('core');
$folder = $appData->getFolder('opengraph');
$file = $folder->getFile($referenceId);
- $response = new DataDownloadResponse($file->getContent(), $referenceId, $reference->getImageContentType());
+ $response = new DataDownloadResponse(
+ $file->getContent(),
+ $referenceId,
+ $reference === null ? $file->getMimeType() : $reference->getImageContentType()
+ );
} catch (NotFoundException|NotPermittedException $e) {
$response = new DataResponse('', Http::STATUS_NOT_FOUND);
}