Skip to content

Commit

Permalink
A fix for mime types handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wizardeur committed Mar 1, 2024
1 parent c9a2fe1 commit a271d23
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 a271d23

Please sign in to comment.