aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-10-14 09:11:51 +0200
committerGitHub <noreply@github.com>2022-10-14 09:11:51 +0200
commitf49ccd140fd5ada0aa640f6642464ad149c980e6 (patch)
tree142eafa2f4d2135d34892e5efac387d5b3493b05 /core
parentaa003dc971eb09c4237c5c7a3fbf64d781957749 (diff)
parent6e03d99ab8ee4510ea44cf54f6d157e81da6e57c (diff)
downloadnextcloud-server-f49ccd140fd5ada0aa640f6642464ad149c980e6.tar.gz
nextcloud-server-f49ccd140fd5ada0aa640f6642464ad149c980e6.zip
Merge pull request #34450 from nextcloud/fix/noid/opengraph-preview-without-cache
Fix reference preview when no server-side cache configured
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);
}