Skip to content

Commit

Permalink
detecting the mimetype of static files by their name, closes #95
Browse files Browse the repository at this point in the history
  • Loading branch information
philiplb committed Jan 31, 2018
1 parent ffb7b3b commit ffd60ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions src/CRUDlex/ControllerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, [
Expand Down

0 comments on commit ffd60ce

Please sign in to comment.