19use RecursiveArrayIterator;
20use RecursiveIteratorIterator;
80 $this->processed =
false;
82 $this->uploadResult = [];
83 $this->rejectedUploadResult = [];
91 if ($this->processed ===
false) {
92 throw new \RuntimeException(
'Can not move unprocessed files.');
103 if ($override_existing && $filesystem->has(
$path)) {
104 $filesystem->delete(
$path);
119 if ($this->processed ===
false) {
120 throw new \RuntimeException(
'Can not move unprocessed files.');
123 if ($this->moved ===
true) {
124 throw new \RuntimeException(
'Can not move the files a second time.');
144 $this->uploadResult = $tempResults;
145 $this->uploadStreams =
null;
215 throw new \InvalidArgumentException(
"No filesystem found for location code \"$location\"");
225 return \ilUtil::getUploadSizeLimitBytes();
234 if ($this->processed ===
false) {
235 $this->processorManager->with($preProcessor);
247 if ($this->processed ===
true) {
254 $uploadedFiles = $this->globalHttpState->request()->getUploadedFiles();
256 foreach ($collectFilesFromNestedFields as
$file) {
260 }
catch (\RuntimeException $e) {
266 $identifier =
$file->getStream()->getMetadata(
'uri');
268 $identifier = is_array($identifier) ?
'' : $identifier;
270 $this->uploadStreams[$identifier] =
$stream;
272 if (
$file->getError() === UPLOAD_ERR_OK) {
280 is_string($identifier)?$identifier:
''
282 $this->uploadResult[$identifier] =
$result;
288 $this->processed =
true;
314 $this->rejectedUploadResult[] =
$result;
323 if ($this->processed) {
324 return array_merge($this->uploadResult, $this->rejectedUploadResult);
340 $uploadedFiles = $this->
flattenUploadedFiles($this->globalHttpState->request()->getUploadedFiles());
342 return (count($uploadedFiles) > 0);
353 $recursiveIterator =
new RecursiveIteratorIterator(
354 new RecursiveArrayIterator(
356 RecursiveArrayIterator::CHILD_ARRAYS_ONLY
358 RecursiveIteratorIterator::LEAVES_ONLY
361 return iterator_to_array($recursiveIterator,
false);
$metadata['__DYNAMIC:1__']
An exception for terminatinating execution or to throw for unit testing.
Class EntryLockingStringMap.
Class ImmutableMapWrapper.
const REJECTED
Upload got rejected by a processor.
Class IllegalStateException.
rejectFailedUpload(UploadedFileInterface $file, Metadata $metadata)
Reject a failed upload with the given metadata.
moveFilesTo($destination, $location=Location::STORAGE)
@inheritDoc
regenerateUploadResultWithPath(UploadResult $result, $path)
Generate an exact copy of the result with the given path.
regenerateUploadResultWithCopyError(UploadResult $result, $errorReason)
Creates a clone of the given result and set the status to rejected with the passed error message.
__construct(PreProcessorManager $processorManager, Filesystems $filesystems, GlobalHttpState $globalHttpState)
FileUploadImpl constructor.
flattenUploadedFiles($uploadedFiles)
uploadSizeLimit()
@inheritDoc
selectFilesystem($location)
Selects the correct filesystem by the given Location constant.
moveOneFileTo(UploadResult $uploadResult, $destination, $location=Location::STORAGE, $file_name='', $override_existing=false)
Moves a single UploadResult to the given destination.void
static ofPsr7Stream(StreamInterface $stream)
Create a FileStream from a Psr7 compliant stream.
process()
Invokes all preprocessors for each uploaded file in the sequence they got registered.
const TEMPORARY
The ILIAS temporary directory.
const CUSTOMIZING
The filesystem within the web root where all the skins and plugins are saved.
const WEB
The filesystem within the ilias web root.
const STORAGE
The filesystem outside of the ilias web root.
Class PreProcessorManager.
Interface GlobalHttpState.
Value object representing a file uploaded through an HTTP request.
$stream
PHP stream implementation.
static filesystems()
Returns the loaded filesystems.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file