ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
XSendfile.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
34 final class XSendfile implements ilFileDeliveryType
35 {
40  public const X_SENDFILE = 'X-Sendfile';
44  public const X_SENDFILE_TEMPORARY = 'X-Sendfile-Temporary';
45 
46 
52  public function __construct(private Services $httpService)
53  {
54  }
55 
56 
60  public function doesFileExists(string $path_to_file): bool
61  {
62  return is_readable($path_to_file);
63  }
64 
65 
69  public function prepare(string $path_to_file, ?FileStream $possible_stream): bool
70  {
71  // Nothing has to be done here
72  return true;
73  }
74 
75 
79  public function deliver(string $path_to_file, bool $file_marked_to_delete): void
80  {
81  $response = $this->httpService->response()
82  ->withHeader(self::X_SENDFILE, realpath($path_to_file));
83  $this->httpService->saveResponse($response);
84  $this->httpService->sendResponse();
85  }
86 
87 
91  public function supportsInlineDelivery(): bool
92  {
93  return true;
94  }
95 
96 
100  public function supportsAttachmentDelivery(): bool
101  {
102  return true;
103  }
104 
105 
109  public function supportsStreaming(): bool
110  {
111  return true;
112  }
113 
114 
118  public function handleFileDeletion(string $path_to_file): bool
119  {
120  return unlink($path_to_file);
121  }
122 }
$response
Definition: xapitoken.php:93
handleFileDeletion(string $path_to_file)
bool
Definition: XSendfile.php:118
prepare(string $path_to_file, ?FileStream $possible_stream)
Definition: XSendfile.php:69
__construct(private Services $httpService)
PHP constructor.
Definition: XSendfile.php:52
deliver(string $path_to_file, bool $file_marked_to_delete)
absolute path to fileThis is needed at this point for header-based delivery methodsvoid ...
Definition: XSendfile.php:79
The base interface for all filesystem streams.
Definition: FileStream.php:31