19 declare(strict_types=1);
51 $this->httpService = $httpState;
60 return is_readable($path_to_file);
70 if ($possible_stream !== null) {
71 $this->file = $possible_stream->detach();
73 $resource = fopen($path_to_file,
'rb');
74 $this->file = $resource ===
false ? null : $resource;
83 public function deliver(
string $path_to_file,
bool $file_marked_to_delete): void
85 $file = $path_to_file;
90 $response = $this->httpService->response()->withStatus(404);
91 $this->httpService->saveResponse(
$response);
95 $size = filesize(
$file);
111 $response = $this->httpService->response()->withHeader(
"Accept-Ranges",
"0-$length");
112 $this->httpService->saveResponse(
$response);
113 $server = $this->httpService->request()->getServerParams();
117 if (isset(
$server[
'HTTP_RANGE'])) {
124 if (strpos(
$range,
',') !==
false) {
129 $this->httpService->saveResponse(
$response);
140 $c_start = $size - substr(
$range, 1);
150 $c_end = ($c_end > $end) ? $end : $c_end;
152 if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
155 $this->httpService->saveResponse(
$response);
162 $length = $end - $start + 1;
163 fseek($fp, (
int) $start);
165 $response = $this->httpService->response()->withStatus(206);
167 $this->httpService->saveResponse(
$response);
173 $this->httpService->saveResponse(
$response);
176 $this->httpService->sendResponse();
180 while (!feof($fp) && ($p = ftell($fp)) <= $end) {
181 if ($p + $buffer > $end) {
184 $buffer = $end - $p + 1;
188 echo fread($fp, $buffer);
226 $this->httpService->sendResponse();
236 return unlink($path_to_file);
ILIAS HTTP Services $httpService
prepare(string $path_to_file, ?FileStream $possible_stream)
bool
handleFileDeletion(string $path_to_file)
bool
__construct(Services $httpState)
PHP constructor.
Interface ilFileDeliveryType.
doesFileExists(string $path_to_file)
deliver(string $path_to_file, bool $file_marked_to_delete)
absolute path to fileThis is needed at this point for header-based delivery methodsvoid ...
supportsAttachmentDelivery()
The base interface for all filesystem streams.