ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
XSendfile.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
34final class XSendfile implements ilFileDeliveryType
35{
36 use HeaderBasedDeliveryHelper;
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}
deliver(string $path_to_file, bool $file_marked_to_delete)
void
Definition: XSendfile.php:79
handleFileDeletion(string $path_to_file)
bool
Definition: XSendfile.php:118
doesFileExists(string $path_to_file)
@inheritDoc
Definition: XSendfile.php:60
prepare(string $path_to_file, ?FileStream $possible_stream)
bool
Definition: XSendfile.php:69
__construct(private Services $httpService)
PHP constructor.
Definition: XSendfile.php:52
Class Services.
Definition: Services.php:38
The base interface for all filesystem streams.
Definition: FileStream.php:32
$response
Definition: xapitoken.php:93