ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
WhitelistFileHeaderPreProcessor.php
Go to the documentation of this file.
1<?php
2
4
8use ILIAS\FileUpload\ScalarTypeCheckAware;
9use Psr\Http\Message\StreamInterface;
10
21{
22 use ScalarTypeCheckAware;
23
27 private $fileHeader;
32
33
39 public function __construct($fileHeader)
40 {
41 $this->stringTypeCheck($fileHeader, 'fileHeader');
42
43 $this->fileHeaderLength = strlen($fileHeader);
44 $this->fileHeader = $fileHeader;
45 }
46
47
51 public function process(FileStream $stream, Metadata $metadata)
52 {
53 $header = $stream->read($this->fileHeaderLength);
54 if (strcmp($this->fileHeader, $header) === 0) {
55 return new ProcessingStatus(ProcessingStatus::OK, 'File header complies with whitelist.');
56 }
57
58 return new ProcessingStatus(ProcessingStatus::REJECTED, 'File header don\'t complies with whitelist.');
59 }
60}
An exception for terminatinating execution or to throw for unit testing.
const REJECTED
Upload got rejected by a processor.
__construct($fileHeader)
WhitelistFileHeaderPreProcessor constructor.
process(FileStream $stream, Metadata $metadata)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...