ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
WhitelistFileHeaderPreProcessor.php
Go to the documentation of this file.
1<?php
2
20
24use ILIAS\FileUpload\ScalarTypeCheckAware;
25
36{
37 use ScalarTypeCheckAware;
38
39 private string $fileHeader;
40 private int $fileHeaderLength;
41
42
46 public function __construct(string $fileHeader)
47 {
48 $this->stringTypeCheck($fileHeader, 'fileHeader');
49
50 $this->fileHeaderLength = strlen($fileHeader);
51 $this->fileHeader = $fileHeader;
52 }
53
54
58 public function process(FileStream $stream, Metadata $metadata): ProcessingStatus
59 {
60 $header = $stream->read($this->fileHeaderLength);
61 if (strcmp($this->fileHeader, $header) === 0) {
62 return new ProcessingStatus(ProcessingStatus::OK, 'File header complies with whitelist.');
63 }
64
65 return new ProcessingStatus(ProcessingStatus::REJECTED, 'File header don\'t complies with whitelist.');
66 }
67}
__construct(string $fileHeader)
WhitelistFileHeaderPreProcessor constructor.
process(FileStream $stream, Metadata $metadata)
@inheritDoc
The base interface for all filesystem streams.
Definition: FileStream.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...