19 declare(strict_types=1);
57 $this->
http->saveResponse($r->withStatus(404));
58 $this->
http->sendResponse();
71 Disposition::ATTACHMENT
75 public function inline(
90 string $download_file_name,
91 ?
string $mime_type =
null,
94 $r = $this->
http->response();
95 $uri = $stream->getMetadata()[
'uri'];
97 if ($stream instanceof
ZIPStream || $stream->getMetadata()[
'uri'] ===
'php://memory') {
98 $this->response_builder = $this->fallback_response_builder;
104 $mime_type ?? mime_content_type($uri),
109 $r = $this->response_builder->buildForStream(
110 $this->
http->request(),
120 $parts = explode(self::SUBREQUEST_SEPARATOR, $token);
124 $sub_request = implode(
'/', array_slice(
$parts, 1));
127 $r = $this->
http->response();
128 $payload = $this->data_signer->verifyStreamToken($token);
133 $mime_type =
$payload->getMimeType();
134 $file_name =
$payload->getFilename();
140 $file_name =
$payload->getFilename();
150 if ($sub_request ===
null) {
159 $this->
http->saveResponse(
160 $this->response_builder->buildForStream(
161 $this->http->request(),
167 $requested_zip = $uri;
168 $sub_request = urldecode($sub_request);
170 $sub_request = explode(
'?', $sub_request)[0];
177 $file_inside_zip_uri = $file_inside_ZIP->getMetadata()[
'uri'];
178 $file_inside_zip_stream = fopen($file_inside_zip_uri,
'rb');
180 if ($file_inside_zip_stream ===
false) {
185 $this->response_builder = $this->fallback_response_builder;
190 $file_inside_zip_uri,
192 basename($sub_request),
197 $this->
http->saveResponse(
198 $this->response_builder->buildForStream(
199 $this->http->request(),
205 $this->
http->sendResponse();
206 $this->
http->close();
211 $suffix = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
212 if (isset($this->mime_type_map[$suffix])) {
213 if (is_array($this->mime_type_map[$suffix]) && isset($this->mime_type_map[$suffix][0])) {
214 return $this->mime_type_map[$suffix][0];
217 return $this->mime_type_map[$suffix];
220 $mime_type = mime_content_type($filename);
221 if ($mime_type ===
'application/octet-stream') {
222 $mime_type = mime_content_type(substr($filename, 64));
224 return $mime_type ?:
'application/octet-stream';
setGeneralHeaders(ResponseInterface $r, string $uri, string $mime_type, string $file_name, Disposition $disposition=Disposition::INLINE)
deliver(FileStream $stream, string $download_file_name, ?string $mime_type=null, Disposition $disposition=Disposition::INLINE)
attached(FileStream $stream, string $download_file_name, ?string $mime_type=null)
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
if(count($parts) !=3) $payload
static ofFileInsideZIP(string $path_to_zip, string $path_inside_zip)
saveAndClose(ResponseInterface $r, ?string $path_to_delete=null)
const SUBREQUEST_SEPARATOR
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
static http()
Fetches the global http state from ILIAS.
__construct(private DataSigner $data_signer, Services $http, ResponseBuilder $response_builder, ResponseBuilder $fallback_response_builder,)
determineMimeType(string $filename)
notFound(ResponseInterface $r)
__construct(Container $dic, ilPlugin $plugin)
deliverFromToken(string $token)
string $download_file_name
The base interface for all filesystem streams.