Fix file type
This commit is contained in:
parent
1abab3fd40
commit
74eeb1a832
|
@ -6,6 +6,7 @@ use App\Models\LinkType;
|
||||||
use App\Models\Link;
|
use App\Models\Link;
|
||||||
use App\Models\Button;
|
use App\Models\Button;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
|
||||||
class LinkTypeViewController extends Controller
|
class LinkTypeViewController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -77,6 +78,25 @@ class LinkTypeViewController extends Controller
|
||||||
return response('File not found', Response::HTTP_NOT_FOUND);
|
return response('File not found', Response::HTTP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->file($fullPath);
|
// Map file extensions to MIME types
|
||||||
|
$mimeTypes = [
|
||||||
|
'js' => 'application/javascript',
|
||||||
|
'css' => 'text/css',
|
||||||
|
'img' => 'image/png',
|
||||||
|
'svg' => 'image/svg+xml',
|
||||||
|
'gif' => 'image/gif',
|
||||||
|
'jpg' => 'image/jpeg',
|
||||||
|
'jpeg' => 'image/jpeg',
|
||||||
|
'png' => 'image/png',
|
||||||
|
'mp4' => 'video/mp4',
|
||||||
|
'mp3' => 'audio/mpeg',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Determine the MIME type using the mapping
|
||||||
|
$mimeType = $mimeTypes[$extension] ?? 'application/octet-stream';
|
||||||
|
|
||||||
|
return response()->file($fullPath, [
|
||||||
|
'Content-Type' => $mimeType
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue