ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
DownloadConsumer.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
4 
6 
12 {
13 
14  public function run() : void
15  {
16  global $DIC;
17 
18  $revision = $this->getRevision();
19 
20  $file_name = $this->file_name_policy->prepareFileNameForConsumer($this->file_name ?? $revision->getInformation()->getTitle());
21  $mime_type = $revision->getInformation()->getMimeType();
22 
23  $response = $DIC->http()->response();
24  if ($this->file_name_policy->isValidExtension($revision->getInformation()->getSuffix())) {
25  $response = $response->withHeader(ResponseHeader::CONTENT_TYPE, $mime_type);
26  } else {
27  $response = $response->withHeader(ResponseHeader::CONTENT_TYPE, 'application/octet-stream');
28  }
29  $response = $response->withHeader(ResponseHeader::CONNECTION, 'close');
30  $response = $response->withHeader(ResponseHeader::ACCEPT_RANGES, 'bytes');
31  $response = $response->withHeader(
33  'attachment'
34  . '; filename="'
35  . $file_name
36  . '"'
37  );
38  $response = $response->withBody($this->storage_handler->getStream($revision));
39 
40  $DIC->http()->saveResponse($response);
41  $DIC->http()->sendResponse();
42  $DIC->http()->close();
43  }
44 
45 }
run()
This runs the actual DeliveryConsumer.
global $DIC
Definition: goto.php:24
$response