ILIAS  release_7 Revision v7.30-3-g800a261c036
XSendfile.php
Go to the documentation of this file.
1<?php
2
4
7
8require_once('./Services/FileDelivery/interfaces/int.ilFileDeliveryType.php');
9
17final class XSendfile implements ilFileDeliveryType
18{
19 use HeaderBasedDeliveryHelper;
20 const X_SENDFILE = 'X-Sendfile';
21 const X_SENDFILE_TEMPORARY = 'X-Sendfile-Temporary';
25 private $httpService;
26
27
34 public function __construct(GlobalHttpState $httpState)
35 {
36 $this->httpService = $httpState;
37 }
38
39
43 public function doesFileExists($path_to_file)
44 {
45 return is_readable($path_to_file);
46 }
47
48
52 public function prepare($path_to_file)
53 {
54 // Nothing has to be done here
55 return true;
56 }
57
58
62 public function deliver($path_to_file, $file_marked_to_delete)
63 {
64 $delivery = function () use ($path_to_file) {
65 $response = $this->httpService->response()
66 ->withHeader(self::X_SENDFILE, realpath($path_to_file));
67 $this->httpService->saveResponse($response);
68 $this->httpService->sendResponse();
69 };
70
71 if ($file_marked_to_delete) {
72 $this->sendFileUnbufferedUsingHeaders($delivery);
73 } else {
74 $delivery();
75 }
76
77 return true;
78 }
79
80
84 public function supportsInlineDelivery()
85 {
86 return true;
87 }
88
89
94 {
95 return true;
96 }
97
98
102 public function supportsStreaming()
103 {
104 return true;
105 }
106
107
111 public function handleFileDeletion($path_to_file)
112 {
113 unlink($path_to_file);
114 }
115}
An exception for terminatinating execution or to throw for unit testing.
__construct(GlobalHttpState $httpState)
PHP constructor.
Definition: XSendfile.php:34
deliver($path_to_file, $file_marked_to_delete)
bool
Definition: XSendfile.php:62
doesFileExists($path_to_file)
@inheritDoc
Definition: XSendfile.php:43
Interface GlobalHttpState.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$response