diff --git a/CHANGELOG.md b/CHANGELOG.md index 683e427..01983a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ CRUDlex Changelog ## 0.13.0 Released: Upcoming - The soft deletion is now optional (but switched on by default) +- Fixed content type of static files by detecting the mimetype by their name ## 0.12.0 Released: 2017-08-22 diff --git a/src/CRUDlex/ControllerProvider.php b/src/CRUDlex/ControllerProvider.php index b1f9475..5e16c73 100644 --- a/src/CRUDlex/ControllerProvider.php +++ b/src/CRUDlex/ControllerProvider.php @@ -11,8 +11,7 @@ namespace CRUDlex; -use League\Flysystem\Adapter\Local; -use League\Flysystem\Filesystem; +use League\Flysystem\Util\MimeType; use Silex\Api\ControllerProviderInterface; use Silex\Application; use Symfony\Component\HttpFoundation\Request; @@ -600,9 +599,8 @@ public function staticFile(Request $request, Application $app) return $this->getNotFoundPage($app, $app['translator']->trans('crudlex.resourceNotFound')); } - $filesystem = new Filesystem(new Local(dirname($file))); - $mimeType = $filesystem->getMimetype(basename($file)); - $size = filesize($file); + $mimeType = MimeType::detectByFilename($file); + $size = filesize($file); $streamedFileResponse = new StreamedFileResponse(); $response = new StreamedResponse($streamedFileResponse->getStreamedFileFunction($file), 200, [