You are here

public function FileUrlRedirect::redirectToFile in File URL 8

Same name and namespace in other branches
  1. 2.0.x src/Controller/FileUrlRedirect.php \Drupal\file_url\Controller\FileUrlRedirect::redirectToFile()

Redirect to the actual file.

Parameters

\Drupal\file\FileInterface $file: The file object.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse The redirect object.

1 string reference to 'FileUrlRedirect::redirectToFile'
file_url.routing.yml in ./file_url.routing.yml
file_url.routing.yml

File

src/Controller/FileUrlRedirect.php, line 26

Class

FileUrlRedirect
Redirects to the file location.

Namespace

Drupal\file_url\Controller

Code

public function redirectToFile(FileInterface $file) {
  $url = $file
    ->toUrl()
    ->toString();
  return new RedirectResponse($url);
}