83 $this->processed =
false;
85 $this->uploadResult = [];
86 $this->rejectedUploadResult = [];
96 $file_stream = $this->uploadStreams[$identifier];
97 $uri = $file_stream->getMetadata(
'uri');
98 $file_stream->close();
100 unset($this->uploadStreams[$identifier]);
101 unset($_FILES[$identifier]);
110 if (!$this->processed) {
111 throw new \RuntimeException(
'Can not move unprocessed files.');
121 $path = rtrim($destination,
"/") .
'/' . ($file_name ==
"" ? $uploadResult->
getName() : $file_name);
122 if ($override_existing && $filesystem->has(
$path)) {
123 $filesystem->delete(
$path);
140 if (!$this->processed) {
141 throw new \RuntimeException(
'Can not move unprocessed files.');
145 throw new \RuntimeException(
'Can not move the files a second time.');
151 foreach ($this->uploadResult as
$key => $uploadResult) {
157 $path = $destination .
'/' . $uploadResult->getName();
165 $this->uploadResult = $tempResults;
166 $this->uploadStreams = null;
234 throw new \InvalidArgumentException(
"No filesystem found for location code \"$location\"");
253 if (!$this->processed) {
254 $this->processorManager->with($preProcessor);
266 if ($this->processed) {
270 $uploadedFiles = $this->globalHttpState->request()->getUploadedFiles();
272 foreach ($collectFilesFromNestedFields as $file) {
273 $metadata =
new Metadata($file->getClientFilename(), $file->getSize(), $file->getClientMediaType());
282 $identifier = $file->getStream()->getMetadata(
'uri');
284 $identifier = is_array($identifier) ?
'' : $identifier;
286 $this->uploadStreams[$identifier] = $stream;
288 if ($file->getError() === UPLOAD_ERR_OK) {
289 $processingResult = $this->processorManager->process($stream, $metadata);
298 $metadata->getFilename(),
299 $metadata->getUploadSize(),
300 $metadata->getMimeType(),
301 $metadata->additionalMetaData(),
303 is_string($identifier) ? $identifier :
'' 305 $this->uploadResult[$identifier] = $result;
311 $this->processed =
true;
334 $this->rejectedUploadResult[] = $result;
343 if ($this->processed) {
344 return array_merge($this->uploadResult, $this->rejectedUploadResult);
360 $uploadedFiles = $this->
flattenUploadedFiles($this->globalHttpState->request()->getUploadedFiles());
362 return ($uploadedFiles !== []);
371 RecursiveArrayIterator::CHILD_ARRAYS_ONLY
373 RecursiveIteratorIterator::LEAVES_ONLY
376 return iterator_to_array($recursiveIterator,
false);
Interface GlobalHttpState.
const REJECTED
Upload got rejected by a processor.
const STORAGE
The filesystem outside of the ilias web root.
GlobalHttpState $globalHttpState
regenerateUploadResultWithCopyError(UploadResult $result, string $errorReason)
Creates a clone of the given result and set the status to rejected with the passed error message...
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class PreProcessorManager.
selectFilesystem(int $location)
Selects the correct filesystem by the given Location constant.
flattenUploadedFiles(array $uploadedFiles)
hardRemoveUpload(string $identifier, string $rejection_message)
This is the very last thing we can do if a preprocessor DENIEs an upload.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(PreProcessorManager $processorManager, Filesystems $filesystems, GlobalHttpState $globalHttpState)
FileUploadImpl constructor.
Class IllegalStateException.
Class EntryLockingStringMap.
PreProcessorManager $processorManager
static getUploadSizeLimitBytes()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
moveFilesTo(string $destination, int $location=Location::STORAGE)
static filesystems()
Returns the loaded filesystems.
array $rejectedUploadResult
rejectFailedUpload(Metadata $metadata)
Reject a failed upload with the given metadata.
moveOneFileTo(UploadResult $uploadResult, string $destination, int $location=Location::STORAGE, string $file_name='', bool $override_existing=false)
Moves a single File (the attributes, metadata and upload-status of which are contained in UploadResul...
const CUSTOMIZING
The filesystem within the web root where all the skins and plugins are saved.
hasBeenProcessed()
Return (bool)true if the current upload has already been processed.
const DENIED
Upload got denied by a processor, the upload will be removed immediately.
Class ImmutableMapWrapper.
regenerateUploadResultWithPath(UploadResult $result, string $path)
Generate an exact copy of the result with the given path.
const TEMPORARY
The ILIAS temporary directory.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class FlySystemFileAccessTest disabled disabled disabled.
const WEB
The filesystem within the ilias web root.
static ofPsr7Stream(StreamInterface $stream)
Create a FileStream from a Psr7 compliant stream.