ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
LegacyDelivery.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
28final class LegacyDelivery extends BaseDelivery
29{
30 public function attached(
31 string $path_to_file,
32 ?string $download_file_name = null,
33 ?string $mime_type = null,
34 ?bool $delete_file = false
35 ): never {
36 $this->deliver(
38 Disposition::ATTACHMENT,
42 );
43 }
44
45 public function inline(
46 string $path_to_file,
47 ?string $download_file_name = null,
48 ?string $mime_type = null,
49 ?bool $delete_file = false
50 ): never {
51 $this->deliver(
52 $path_to_file,
53 Disposition::INLINE,
57 );
58 }
59
60 private function deliver(
61 string $path_to_file,
63 ?string $download_file_name = null,
64 ?string $mime_type = null,
65 ?bool $delete_file = false
66 ): never {
67 // The content domain is reserved for signed token delivery via deliver.php.
68 // Legacy delivery must never serve files on the content host.
69 if ($this->isRequestOnContentHost()) {
70 $this->notFound($this->http->response());
71 }
72
73 // Header based delivery (X-Sendfile, X-Accel-Redirect) opens the file only after PHP has
74 // finished, when the shutdown function of saveAndClose() has already deleted it.
75 // See https://mantis.ilias.de/view.php?id=48312
76 if ($delete_file && !$this->response_builder->supportFileDeletion()) {
77 $this->response_builder = $this->fallback_response_builder;
78 }
79 $r = $this->setGeneralHeaders(
80 $this->http->response(),
81 $path_to_file,
82 $mime_type ?? mime_content_type($path_to_file),
85 );
86 $r = $this->response_builder->buildForStream(
87 $this->http->request(),
88 $r,
90 );
91 $this->saveAndClose($r, $delete_file ? $path_to_file : null);
92 }
93}
attached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, ?bool $delete_file=false)
deliver(string $path_to_file, Disposition $disposition, ?string $download_file_name=null, ?string $mime_type=null, ?bool $delete_file=false)
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Definition: Streams.php:32
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:64
static http()
Fetches the global http state from ILIAS.
if(!file_exists('../ilias.ini.php'))