ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer Class Reference
+ Inheritance diagram for ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer:
+ Collaboration diagram for ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer:

Public Member Functions

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

Protected Member Functions

 getDisposition ()
 

Private Attributes

const NON_VALID_EXTENSION_MIME = \ILIAS\FileUpload\MimeType::APPLICATION__OCTET_STREAM
 
ILIAS HTTP Services $http
 
ILIAS FileDelivery Delivery StreamDelivery $delivery
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\ResourceStorage\Consumer\BaseConsumer
int $revision_number = null
 
string $file_name = ''
 
StorableResource $resource
 
StreamAccess $stream_access
 
FileNamePolicy $file_name_policy
 

Detailed Description

Definition at line 31 of file BaseHTTPResponseBasedConsumer.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::__construct ( \ILIAS\HTTP\Services  $http,
StorableResource  $resource,
StreamAccess  $stream_access,
FileNamePolicy  $file_name_policy 
)

Definition at line 38 of file BaseHTTPResponseBasedConsumer.php.

References $DIC, ILIAS\MetaData\Repository\Validation\Data\__construct(), and ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer\getDisposition().

43  {
44  global $DIC;
45  $this->delivery = $DIC->fileDelivery()->delivery();
47  }
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ getDisposition()

ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::getDisposition ( )
abstractprotected

◆ run()

ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::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 51 of file BaseHTTPResponseBasedConsumer.php.

References ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer\getDisposition().

51  : void
52  {
53  $revision = $this->getRevision();
54  $filename_with_extension = $this->file_name ?? $revision->getInformation()->getTitle();
55  $extension = pathinfo($filename_with_extension, PATHINFO_EXTENSION);
56  $file_name_for_consumer = $this->file_name_policy->prepareFileNameForConsumer($filename_with_extension);
57 
58  $mime_type = $this->file_name_policy->isValidExtension($extension)
59  ? $revision->getInformation()->getMimeType()
60  : self::NON_VALID_EXTENSION_MIME;
61 
62  // Build Response
63  $revision = $this->stream_access->populateRevision($revision);
64 
65  switch ($this->getDisposition()) {
66  case 'attachment':
67  $this->delivery->attached(
68  $revision->maybeStreamResolver()?->getStream(),
69  $file_name_for_consumer,
70  $mime_type
71  );
72  break;
73  case 'inline':
74  $this->delivery->inline(
75  $revision->maybeStreamResolver()?->getStream(),
76  $file_name_for_consumer,
77  $mime_type
78  );
79  break;
80  default:
81  throw new \InvalidArgumentException('Invalid disposition');
82  }
83  }
+ Here is the call graph for this function:

Field Documentation

◆ $delivery

ILIAS FileDelivery Delivery StreamDelivery ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::$delivery
private

Definition at line 36 of file BaseHTTPResponseBasedConsumer.php.

◆ $http

ILIAS HTTP Services ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::$http
private

Definition at line 35 of file BaseHTTPResponseBasedConsumer.php.

◆ NON_VALID_EXTENSION_MIME

const ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::NON_VALID_EXTENSION_MIME = \ILIAS\FileUpload\MimeType::APPLICATION__OCTET_STREAM
private

Definition at line 34 of file BaseHTTPResponseBasedConsumer.php.


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