ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\ResourceStorage\Consumer\InlineConsumer Class Reference
+ Inheritance diagram for ILIAS\ResourceStorage\Consumer\InlineConsumer:
+ Collaboration diagram for ILIAS\ResourceStorage\Consumer\InlineConsumer:

Public Member Functions

 run ()
 This runs the actual DeliveryConsumer. More...
 
- Public Member Functions inherited from ILIAS\ResourceStorage\Consumer\BaseConsumer
 __construct (StorableResource $resource, StorageHandler $storage_handler, FileNamePolicy $file_name_policy)
 DownloadConsumer constructor. More...
 
 run ()
 This runs the actual DeliveryConsumer. More...
 
 setRevisionNumber (int $revision_number)
 
 overrideFileName (string $file_name)
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\ResourceStorage\Consumer\BaseConsumer
 $storage_handler
 
 $resource
 
 $revision_number = null
 
 $file_name_policy
 
 $file_name = ''
 

Detailed Description

Definition at line 11 of file InlineConsumer.php.

Member Function Documentation

◆ run()

ILIAS\ResourceStorage\Consumer\InlineConsumer::run ( )

This runs the actual DeliveryConsumer.

E.g. a DownloadConsumer will pass the Stream of a Ressource to the HTTP-Service and download the file.

Implements ILIAS\ResourceStorage\Consumer\DeliveryConsumer.

Definition at line 14 of file InlineConsumer.php.

References $DIC, ILIAS\ResourceStorage\Consumer\BaseConsumer\$file_name, $response, ILIAS\HTTP\Response\ResponseHeader\ACCEPT_RANGES, ILIAS\HTTP\Response\ResponseHeader\CONNECTION, ILIAS\HTTP\Response\ResponseHeader\CONTENT_DISPOSITION, and ILIAS\HTTP\Response\ResponseHeader\CONTENT_TYPE.

14  : 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  'inline'
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  }
global $DIC
Definition: goto.php:24
$response

The documentation for this class was generated from the following file: