Skip to content

Commit

Permalink
Merge pull request #2362 from wizardeur/file-mimetype-fix
Browse files Browse the repository at this point in the history
A fix for mime types handling
  • Loading branch information
marcelfolaron authored Mar 1, 2024
2 parents c9a2fe1 + a271d23 commit 9329cb0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/Domain/Files/Controllers/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,19 @@ private function getFileLocally($encName, $ext, $module, $realName): Response
$path_parts = pathinfo($fullPath);

if ($ext == 'pdf') {
$mime_type = 'application/pdf';
header('Content-type: application/pdf');
header("Content-Disposition: inline; filename=\"" . $realName . "." . $ext . "\"");
} elseif ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'gif' || $ext == 'png') {
$mime_type = $mimes[$ext];
header('Content-type: ' . $mimes[$ext]);
header('Content-disposition: inline; filename="' . $realName . "." . $ext . '";');
} elseif ($ext == 'svg') {
$mime_type = 'image/svg+xml';
header('Content-type: image/svg+xml');
header('Content-disposition: attachment; filename="' . $realName . "." . $ext . '";');
} else {
$mime_type = 'application/octet-stream';
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"" . $realName . "." . $ext . "\"");
}
Expand All @@ -102,7 +106,7 @@ private function getFileLocally($encName, $ext, $module, $realName): Response


$oStreamResponse = new StreamedResponse();
$oStreamResponse->headers->set("Content-Type", $mimes[$ext] );
$oStreamResponse->headers->set("Content-Type", $mime_type );
$oStreamResponse->headers->set("Content-Length", $sFileSize);
$oStreamResponse->headers->set("ETag", $sEtag);

Expand Down

0 comments on commit 9329cb0

Please sign in to comment.