Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Controller/Admin/Asset/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class AssetController extends ElementControllerBase implements KernelControllerE
use ElementEditLockHelperTrait;
use ApplySchedulerDataTrait;
use UserNameTrait;
final const PDF_MIMETYPE = 'application/pdf';

protected Asset\Service $_assetService;

Expand Down Expand Up @@ -933,7 +934,7 @@ public function showVersionAction(Request $request, Environment $twig): Response
throw $this->createAccessDeniedHttpException('Permission denied, version id [' . $id . ']');
}

if ($asset->getMimeType() === 'application/pdf') {
if ($asset instanceof Asset\Document && $asset->getMimeType() === self::PDF_MIMETYPE) {
$scanResponse = $this->getResponseByScanStatus($asset, false);
if ($scanResponse) {
return $scanResponse;
Expand Down Expand Up @@ -1432,7 +1433,7 @@ public function getPreviewDocumentAction(
}

if ($asset->isAllowed('view')) {
if ($asset->getMimeType() === 'application/pdf') {
if ($asset instanceof Asset\Document && $asset->getMimeType() === self::PDF_MIMETYPE) {
$scanResponse = $this->getResponseByScanStatus($asset);
if ($scanResponse) {
return $scanResponse;
Expand All @@ -1444,7 +1445,7 @@ public function getPreviewDocumentAction(
return new StreamedResponse(function () use ($stream) {
fpassthru($stream);
}, 200, [
'Content-Type' => 'application/pdf',
'Content-Type' => self::PDF_MIMETYPE,
]);
} else {
throw $this->createNotFoundException('Unable to get preview for asset ' . $asset->getId());
Expand Down Expand Up @@ -1484,7 +1485,7 @@ protected function getDocumentPreviewPdf(Asset\Document $asset)
{
$stream = null;

if ($asset->getMimeType() == 'application/pdf') {
if ($asset->getMimeType() == self::PDF_MIMETYPE) {
$stream = $asset->getStream();
}

Expand Down
Loading