9 use Symfony\Component\HttpFoundation\BinaryFileResponse;
 
   10 use Symfony\Component\HttpFoundation\Response;
 
   48         if (!preg_match(
'~serve-file/e(\d+)/l(\d+)/d([ia])/c([01])/([a-zA-Z0-9\-_]+)/(.*)$~', 
$path, $m)) {
 
   49             return $response->setStatusCode(400)->setContent(
'Malformatted request URL');
 
   52         list(, 
$expires, $last_updated, $disposition, $use_cookie, 
$mac, $path_from_dataroot) = $m;
 
   55             return $response->setStatusCode(403)->setContent(
'URL has expired');
 
   60         $path_from_dataroot = str_replace(
'%20', 
' ', $path_from_dataroot);
 
   64             'last_updated' => (
int) $last_updated,
 
   65             'disposition' => $disposition,
 
   66             'path' => $path_from_dataroot,
 
   67             'use_cookie' => (int) $use_cookie,
 
   69         if ((
bool) $use_cookie) {
 
   70             $hmac_data[
'cookie'] = $this->getCookieValue(
$request);
 
   75         $hmac = $this->hmac->getHmac($hmac_data);
 
   77             return $response->setStatusCode(403)->setContent(
'HMAC mismatch');
 
   81         if (str_starts_with($path_from_dataroot, 
':')) {
 
   82             $path_from_dataroot = Base64Url::decode(substr($path_from_dataroot, 1));
 
   85         $filenameonfilestore = 
"{$this->config->dataroot}{$path_from_dataroot}";
 
   87         if (!is_readable($filenameonfilestore)) {
 
   88             return $response->setStatusCode(404)->setContent(
'File not found');
 
   91         $actual_last_updated = filemtime($filenameonfilestore);
 
   92         if ($actual_last_updated != $last_updated) {
 
   93             return $response->setStatusCode(403)->setContent(
'URL has expired');
 
   96         $if_none_match = 
$request->headers->get(
'if_none_match');
 
   97         if (!empty($if_none_match)) {
 
   99             $request->headers->set(
'if_none_match', str_replace(
'-gzip', 
'', $if_none_match));
 
  102         $etag = 
'"' . $actual_last_updated . 
'"';
 
  108         $public = !(bool) $use_cookie;
 
  109         $content_disposition = $disposition == 
'i' ? 
'inline' : 
'attachment';
 
  112             'Content-Type' => $this->mimetype->getMimeType($filenameonfilestore),
 
  113             'X-Content-Type-Options' => 
'nosniff',
 
  115         $response = 
new BinaryFileResponse($filenameonfilestore, 200, 
$headers, $public, $content_disposition);
 
  117         $sendfile_type = $this->config->x_sendfile_type;
 
  118         if ($sendfile_type) {
 
  119             $request->headers->set(
'X-Sendfile-Type', $sendfile_type);
 
  121             $mapping = (string) $this->config->x_accel_mapping;
 
  122             $request->headers->set(
'X-Accel-Mapping', $mapping);
 
  148         $config = $this->config->getCookieConfig();
 
  149         $session_name = 
$config[
'session'][
'name'];
 
  150         return $request->cookies->get($session_name, 
'');
 
if(empty($entity_guid)||empty($recipient)||empty($muted_settings)||empty($hmac_token)) $hmac
 
__construct(protected HmacFactory $hmac, protected Config $config, protected MimeTypeService $mimetype)
Constructor.
 
getResponse(Request $request)
Handle a request for a file.
 
Public service related to MIME type detection.
 
Encode and decode Base 64 URL.
 
Provides a factory for HMAC objects.
 
Functions for use as event handlers or other situations where you need a globally accessible callable...
 
static normalizeTime($time)
Returns DateTime object based on time representation.
 
$config
Advanced site settings, debugging section.