public function GetFile::deliver in Responsive Favicons 8
Attempts to send the raw file back in the response.
Parameters
$request: a Request object.
File
- src/
Controller/ GetFile.php, line 48
Class
- GetFile
- Class GetFile.
Namespace
Drupal\responsive_favicons\ControllerCode
public function deliver(Request $request) {
// Get the file.
$file = $this
->getFile($request
->getRequestUri());
if (!is_object($file) || !is_file($file->uri) || !is_readable($file->uri)) {
throw new NotFoundHttpException();
}
$response = new Response();
$response->headers
->set('Content-Type', $file->filemime);
$response->headers
->set('Content-Disposition', 'inline');
$response->headers
->set('Content-Length', $file->filesize);
$response
->setContent(file_get_contents($file->uri));
$response
->prepare($request);
$response
->send();
exit;
}