34use RecursiveArrayIterator;
35use RecursiveIteratorIterator;
89 $file_stream = $this->uploadStreams[$identifier];
90 $uri = $file_stream->getMetadata(
'uri');
91 $file_stream->close();
93 unset($this->uploadStreams[$identifier]);
94 unset($_FILES[$identifier]);
103 if (!$this->processed) {
104 throw new \RuntimeException(
'Can not move unprocessed files.');
114 $path = rtrim($destination,
"/") .
'/' . ($file_name ===
"" ?
$uploadResult->getName() : $file_name);
115 if ($override_existing && $filesystem->has($path)) {
116 $filesystem->delete($path);
133 if (!$this->processed) {
134 throw new \RuntimeException(
'Can not move unprocessed files.');
138 throw new \RuntimeException(
'Can not move the files a second time.');
158 $this->uploadResult = $tempResults;
159 $this->uploadStreams =
null;
222 default =>
throw new \InvalidArgumentException(
"No filesystem found for location code \"$location\""),
241 if (!$this->processed) {
242 $this->processorManager->with($preProcessor);
254 if ($this->processed) {
258 $uploadedFiles = $this->globalHttpState->request()->getUploadedFiles();
260 foreach ($collectFilesFromNestedFields as $file) {
261 $metadata =
new Metadata($file->getClientFilename(), $file->getSize(), $file->getClientMediaType());
264 }
catch (\RuntimeException) {
270 $identifier = $file->getStream()->getMetadata(
'uri');
272 $identifier = is_array($identifier) ?
'' : $identifier;
274 $this->uploadStreams[$identifier] = $stream;
276 if ($file->getError() === UPLOAD_ERR_OK) {
277 $processingResult = $this->processorManager->process($stream, $metadata);
286 $metadata->getFilename(),
287 $metadata->getUploadSize(),
288 $metadata->getMimeType(),
289 $metadata->additionalMetaData(),
291 is_string($identifier) ? $identifier :
''
293 $this->uploadResult[$identifier] = $result;
299 $this->processed =
true;
322 $this->rejectedUploadResult[] = $result;
331 if ($this->processed) {
332 return array_merge($this->uploadResult, $this->rejectedUploadResult);
348 $uploadedFiles = $this->
flattenUploadedFiles($this->globalHttpState->request()->getUploadedFiles());
350 return ($uploadedFiles !== []);
356 $recursiveIterator =
new RecursiveIteratorIterator(
357 new RecursiveArrayIterator(
359 RecursiveArrayIterator::CHILD_ARRAYS_ONLY
361 RecursiveIteratorIterator::LEAVES_ONLY
364 return iterator_to_array($recursiveIterator,
false);
Class EntryLockingStringMap.
Class ImmutableMapWrapper.
Class IllegalStateException.
__construct(private PreProcessorManager $processorManager, private Filesystems $filesystems, private GlobalHttpState $globalHttpState, private ?PhpUploadLimit $upload_limit=null)
FileUploadImpl constructor.
hardRemoveUpload(string $identifier, ProcessingStatus $status)
@description This is the very last thing we can do if a preprocessor DENIEs an upload.
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...
regenerateUploadResultWithCopyError(UploadResult $result, string $errorReason)
Creates a clone of the given result and set the status to rejected with the passed error message.
uploadSizeLimit()
@inheritDoc
selectFilesystem(int $location)
Selects the correct filesystem by the given Location constant.
flattenUploadedFiles(array $uploadedFiles)
regenerateUploadResultWithPath(UploadResult $result, string $path)
Generate an exact copy of the result with the given path.
rejectFailedUpload(Metadata $metadata)
Reject a failed upload with the given metadata.
hasBeenProcessed()
Return (bool)true if the current upload has already been processed.
moveFilesTo(string $destination, int $location=Location::STORAGE)
@inheritDoc
array $rejectedUploadResult
Indicates general problems with the input or output operations.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
static ofPsr7Stream(StreamInterface $stream)
Create a FileStream from a Psr7 compliant stream.
static getPhpUploadSizeLimitInBytes()
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.
The filesystem interface provides the public interface for the Filesystem service API consumer.
The Filesystems interface defines the access methods which can be used to fetch the different filesys...
The base interface for all filesystem streams.
Interface GlobalHttpState.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static filesystems()
Returns the loaded filesystems.