ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
XAccelResponseBuilder.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
31 {
35  private const DATA = 'data';
39  private const SECURED_DATA = 'secured-data';
43  private const X_ACCEL_REDIRECT_HEADER = 'X-Accel-Redirect';
44 
45  public function getName(): string
46  {
47  return 'x-accel';
48  }
49 
50  public function buildForStream(
51  ServerRequestInterface $request,
52  ResponseInterface $response,
53  FileStream $stream,
54  ): ResponseInterface {
55  $path_to_file = $stream->getStream()->getMetadata('uri');
56  if (str_starts_with((string) $path_to_file, './' . self::DATA . '/')) {
57  $path_to_file = str_replace(
58  './' . self::DATA . '/',
59  '/' . self::SECURED_DATA
60  . '/',
61  $path_to_file
62  );
63  }
64 
65  return $response->withHeader(
66  self::X_ACCEL_REDIRECT_HEADER,
67  $path_to_file
68  );
69  }
70 
71  public function supportPartial(): bool
72  {
73  return true;
74  }
75 
76  public function supportStreaming(): bool
77  {
78  return true;
79  }
80 
81  public function supportFileDeletion(): bool
82  {
83  return false;
84  }
85 
86  public function supportsInlineDelivery(): bool
87  {
88  return true;
89  }
90 
91  public function supportsAttachmentDelivery(): bool
92  {
93  return true;
94  }
95 }
$response
Definition: xapitoken.php:93
buildForStream(ServerRequestInterface $request, ResponseInterface $response, FileStream $stream,)
The base interface for all filesystem streams.
Definition: FileStream.php:31