ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
XAccelResponseBuilder.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
31 {
32  private const DATA = 'data';
33  private const SECURED_DATA = 'secured-data';
34  private const X_ACCEL_REDIRECT_HEADER = 'X-Accel-Redirect';
35 
36  public function getName(): string
37  {
38  return 'x-accel';
39  }
40 
41  public function buildForStream(
42  ServerRequestInterface $request,
43  ResponseInterface $response,
44  FileStream $stream,
45  ): ResponseInterface {
46  $path_to_file = $stream->getMetadata('uri');
47  if (str_starts_with((string) $path_to_file, './' . self::DATA . '/')) {
48  $path_to_file = str_replace(
49  './' . self::DATA . '/',
50  '/' . self::SECURED_DATA
51  . '/',
52  $path_to_file
53  );
54  }
55 
56  return $response->withHeader(
57  self::X_ACCEL_REDIRECT_HEADER,
58  $path_to_file
59  );
60  }
61 
62  public function supportPartial(): bool
63  {
64  return true;
65  }
66 
67  public function supportStreaming(): bool
68  {
69  return true;
70  }
71 
72  public function supportFileDeletion(): bool
73  {
74  return false;
75  }
76 
77  public function supportsInlineDelivery(): bool
78  {
79  return true;
80  }
81 
82  public function supportsAttachmentDelivery(): bool
83  {
84  return true;
85  }
86 }
$response
Definition: xapitoken.php:90
buildForStream(ServerRequestInterface $request, ResponseInterface $response, FileStream $stream,)
The base interface for all filesystem streams.
Definition: FileStream.php:31