‪TYPO3CMS  11.5
ResourceStorage.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\EventDispatcher\EventDispatcherInterface;
19 use Psr\Http\Message\ResponseInterface;
20 use Psr\Http\Message\ServerRequestInterface;
91 
125 {
131  protected ‪$driver;
132 
138  protected ‪$storageRecord;
139 
145  protected ‪$configuration;
146 
150  protected ‪$fileProcessingService;
151 
160  protected ‪$evaluatePermissions = false;
161 
167  protected ‪$fileMounts = [];
168 
175  protected ‪$userPermissions = [];
176 
183  protected ‪$capabilities;
184 
188  protected ‪$eventDispatcher;
189 
193  protected ‪$processingFolder;
194 
200  protected ‪$processingFolders;
201 
207  protected ‪$isOnline;
208 
212  protected ‪$isDefault = false;
213 
220 
224  public const ‪PROCESSING_FOLDER_LEVELS = 2;
225 
233  public function ‪__construct(‪DriverInterface ‪$driver, array ‪$storageRecord, ?EventDispatcherInterface ‪$eventDispatcher = null)
234  {
235  $this->storageRecord = ‪$storageRecord;
236  $this->eventDispatcher = ‪$eventDispatcher ?? GeneralUtility::makeInstance(EventDispatcherInterface::class);
237  if (is_array(‪$storageRecord['configuration'] ?? null)) {
238  $this->configuration = ‪$storageRecord['configuration'];
239  } elseif (!empty(‪$storageRecord['configuration'] ?? '')) {
240  $this->configuration = GeneralUtility::makeInstance(FlexFormService::class)->convertFlexFormContentToArray(‪$storageRecord['configuration']);
241  } else {
242  $this->configuration = [];
243  }
244  $this->capabilities =
245  ($this->storageRecord['is_browsable'] ?? null ? ‪self::CAPABILITY_BROWSABLE : 0) |
246  ($this->storageRecord['is_public'] ?? null ? self::CAPABILITY_PUBLIC : 0) |
247  ($this->storageRecord['is_writable'] ?? null ? ‪self::CAPABILITY_WRITABLE : 0) |
248  // Always let the driver decide whether to set this capability
249  self::CAPABILITY_HIERARCHICAL_IDENTIFIERS;
250 
251  $this->driver = ‪$driver;
252  $this->driver->‪setStorageUid(‪$storageRecord['uid'] ?? null);
253  $this->driver->mergeConfigurationCapabilities($this->capabilities);
254  try {
255  $this->driver->processConfiguration();
256  } catch (‪InvalidConfigurationException $e) {
257  // Configuration error
258  $this->‪isOnline = false;
259 
260  $message = sprintf(
261  'Failed initializing storage [%d] "%s", error: %s',
262  $this->‪getUid(),
263  $this->‪getName(),
264  $e->getMessage()
265  );
266 
267  // create a dedicated logger instance because we need a logger in the constructor
268  GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class)->error($message);
269  }
270  $this->driver->initialize();
271  $this->capabilities = $this->driver->getCapabilities();
272 
273  $this->‪isDefault = (isset(‪$storageRecord['is_default']) && ‪$storageRecord['is_default'] == 1);
275  }
276 
282  public function ‪getConfiguration()
283  {
285  }
286 
292  public function ‪setConfiguration(array ‪$configuration)
293  {
294  $this->configuration = ‪$configuration;
295  }
296 
302  public function ‪getStorageRecord()
303  {
305  }
306 
313  public function ‪setDriver(DriverInterface ‪$driver)
314  {
315  $this->driver = ‪$driver;
316  return ‪$this;
317  }
318 
324  protected function ‪getDriver()
325  {
326  return ‪$this->driver;
327  }
328 
334  public function ‪getName()
335  {
336  return $this->storageRecord['name'];
337  }
338 
344  public function ‪getUid()
345  {
346  return (int)($this->storageRecord['uid'] ?? 0);
347  }
348 
354  public function ‪hasChildren()
355  {
356  return true;
357  }
358 
365  public function ‪isFallbackStorage(): bool
366  {
367  return $this->‪getUid() === 0;
368  }
369 
370  /*********************************
371  * Capabilities
372  ********************************/
382  public function ‪getCapabilities()
383  {
384  return (int)‪$this->capabilities;
385  }
386 
393  protected function ‪hasCapability($capability)
394  {
395  return ($this->capabilities & $capability) == $capability;
396  }
397 
406  public function ‪isPublic()
407  {
408  return $this->‪hasCapability(self::CAPABILITY_PUBLIC);
409  }
410 
417  public function ‪isWritable()
418  {
419  return $this->‪hasCapability(self::CAPABILITY_WRITABLE);
420  }
421 
427  public function ‪isBrowsable()
428  {
429  return $this->‪isOnline() && $this->‪hasCapability(self::CAPABILITY_BROWSABLE);
430  }
431 
437  public function ‪hasHierarchicalIdentifiers(): bool
438  {
439  return $this->‪hasCapability(self::CAPABILITY_HIERARCHICAL_IDENTIFIERS);
440  }
441 
451  public function ‪searchFiles(‪FileSearchDemand $searchDemand, ?‪Folder $folder = null, bool $useFilters = true): ‪FileSearchResultInterface
452  {
453  $folder = $folder ?? $this->‪getRootLevelFolder();
454  if (!$folder->‪checkActionPermission('read')) {
455  return new ‪EmptyFileSearchResult();
456  }
457 
460  $searchDemand->‪withFolder($folder)
461  ),
462  ‪$this->driver,
463  $useFilters ? ‪$this->getFileAndFolderNameFilters() : []
464  );
465  }
466 
472  public function ‪usesCaseSensitiveIdentifiers()
473  {
474  return $this->driver->isCaseSensitiveFileSystem();
475  }
476 
482  public function ‪isOnline()
483  {
484  if ($this->‪isOnline === null) {
485  if ($this->‪getUid() === 0) {
486  $this->‪isOnline = true;
487  }
488  // the storage is not marked as online for a longer time
489  if ($this->storageRecord['is_online'] == 0) {
490  $this->‪isOnline = false;
491  }
492  if ($this->‪isOnline !== false) {
493  if ((‪$GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
494  && ‪ApplicationType::fromRequest(‪$GLOBALS['TYPO3_REQUEST'])->isFrontend()
495  ) {
496  // All files are ALWAYS available in the frontend
497  $this->‪isOnline = true;
498  } else {
499  // check if the storage is disabled temporary for now
500  $registryObject = GeneralUtility::makeInstance(Registry::class);
501  $offlineUntil = $registryObject->get('core', 'sys_file_storage-' . $this->‪getUid() . '-offline-until');
502  if ($offlineUntil && $offlineUntil > time()) {
503  $this->‪isOnline = false;
504  } else {
505  $this->‪isOnline = true;
506  }
507  }
508  }
509  }
510  return ‪$this->isOnline;
511  }
512 
518  public function ‪autoExtractMetadataEnabled()
519  {
520  return !empty($this->storageRecord['auto_extract_metadata']);
521  }
522 
530  public function ‪markAsPermanentlyOffline()
531  {
532  if ($this->‪getUid() > 0) {
533  // @todo: move this to the storage repository
534  GeneralUtility::makeInstance(ConnectionPool::class)
535  ->getConnectionForTable('sys_file_storage')
536  ->update(
537  'sys_file_storage',
538  ['is_online' => 0],
539  ['uid' => (int)$this->‪getUid()]
540  );
541  }
542  $this->storageRecord['is_online'] = 0;
543  $this->‪isOnline = false;
544  }
545 
552  public function ‪markAsTemporaryOffline()
553  {
554  $registryObject = GeneralUtility::makeInstance(Registry::class);
555  $registryObject->set('core', 'sys_file_storage-' . $this->‪getUid() . '-offline-until', time() + 60 * 5);
556  $this->storageRecord['is_online'] = 0;
557  $this->‪isOnline = false;
558  }
559 
560  /*********************************
561  * User Permissions / File Mounts
562  ********************************/
572  public function ‪addFileMount($folderIdentifier, $additionalData = [])
573  {
574  // check for the folder before we add it as a filemount
575  if ($this->driver->folderExists($folderIdentifier) === false) {
576  // if there is an error, this is important and should be handled
577  // as otherwise the user would see the whole storage without any restrictions for the filemounts
578  throw new ‪FolderDoesNotExistException('Folder for file mount ' . $folderIdentifier . ' does not exist.', 1334427099);
579  }
580  $data = $this->driver->getFolderInfoByIdentifier($folderIdentifier);
581  $folderObject = $this->‪createFolderObject($data['identifier'], $data['name']);
582  // Use the canonical identifier instead of the user provided one!
583  $folderIdentifier = $folderObject->getIdentifier();
584  if (
585  !empty($this->fileMounts[$folderIdentifier])
586  && empty($this->fileMounts[$folderIdentifier]['read_only'])
587  && !empty($additionalData['read_only'])
588  ) {
589  // Do not overwrite a regular mount with a read only mount
590  return;
591  }
592  if (empty($additionalData)) {
593  $additionalData = [
594  'path' => $folderIdentifier,
595  'title' => $folderIdentifier,
596  'folder' => $folderObject,
597  ];
598  } else {
599  $additionalData['folder'] = $folderObject;
600  if (!isset($additionalData['title'])) {
601  $additionalData['title'] = $folderIdentifier;
602  }
603  }
604  $this->fileMounts[$folderIdentifier] = $additionalData;
605  }
606 
612  public function ‪getFileMounts()
613  {
614  return ‪$this->fileMounts;
615  }
616 
625  public function ‪isWithinFileMountBoundaries($subject, $checkWriteAccess = false)
626  {
627  if (!$this->evaluatePermissions) {
628  return true;
629  }
630  $isWithinFileMount = false;
631  if (!$subject) {
632  $subject = $this->‪getRootLevelFolder();
633  }
634  $identifier = $subject->getIdentifier();
635 
636  // Allow access to processing folder
637  if ($this->‪isWithinProcessingFolder($identifier)) {
638  $isWithinFileMount = true;
639  } else {
640  // Check if the identifier of the subject is within at
641  // least one of the file mounts
642  $writableFileMountAvailable = false;
643  foreach ($this->fileMounts as $fileMount) {
645  $folder = $fileMount['folder'];
646  if ($this->driver->isWithin($folder->‪getIdentifier(), $identifier)) {
647  $isWithinFileMount = true;
648  if (!$checkWriteAccess) {
649  break;
650  }
651  if (empty($fileMount['read_only'])) {
652  $writableFileMountAvailable = true;
653  break;
654  }
655  }
656  }
657  $isWithinFileMount = $checkWriteAccess ? $writableFileMountAvailable : $isWithinFileMount;
658  }
659  return $isWithinFileMount;
660  }
661 
669  {
670  $this->evaluatePermissions = (bool)‪$evaluatePermissions;
671  }
672 
679  public function ‪getEvaluatePermissions()
680  {
682  }
683 
689  public function ‪setUserPermissions(array ‪$userPermissions)
690  {
691  $this->userPermissions = ‪$userPermissions;
692  }
693 
702  public function ‪checkUserActionPermission($action, $type)
703  {
704  if (!$this->evaluatePermissions) {
705  return true;
706  }
707 
708  $allow = false;
709  if (!empty($this->userPermissions[strtolower($action) . ucfirst(strtolower($type))])) {
710  $allow = true;
711  }
712 
713  return $allow;
714  }
715 
729  public function ‪checkFileActionPermission($action, ‪FileInterface $file)
730  {
731  $isProcessedFile = $file instanceof ‪ProcessedFile;
732  // Check 1: Allow editing meta data of a file if it is in mount boundaries of a writable file mount
733  if ($action === 'editMeta') {
734  return !$isProcessedFile && $this->‪isWithinFileMountBoundaries($file, true);
735  }
736  // Check 2: Does the user have permission to perform the action? e.g. "readFile"
737  if (!$isProcessedFile && $this->‪checkUserActionPermission($action, 'File') === false) {
738  return false;
739  }
740  // Check 3: No action allowed on files for denied file extensions
741  if (!$this->‪checkValidFileExtension($file)) {
742  return false;
743  }
744  $isReadCheck = false;
745  if (in_array($action, ['read', 'copy', 'move', 'replace'], true)) {
746  $isReadCheck = true;
747  }
748  $isWriteCheck = false;
749  if (in_array($action, ['add', 'write', 'move', 'rename', 'replace', 'delete'], true)) {
750  $isWriteCheck = true;
751  }
752  // Check 4: Does the user have the right to perform the action?
753  // (= is he within the file mount borders)
754  if (!$isProcessedFile && !$this->‪isWithinFileMountBoundaries($file, $isWriteCheck)) {
755  return false;
756  }
757 
758  $isMissing = false;
759  if (!$isProcessedFile && $file instanceof ‪File) {
760  $isMissing = $file->isMissing();
761  }
762 
763  if ($this->driver->fileExists($file->‪getIdentifier()) === false) {
764  $file->setMissing(true);
765  $isMissing = true;
766  }
767 
768  // Check 5: Check the capabilities of the storage (and the driver)
769  if ($isWriteCheck && ($isMissing || !$this->‪isWritable())) {
770  return false;
771  }
772 
773  // Check 6: "File permissions" of the driver (only when file isn't marked as missing)
774  if (!$isMissing) {
775  $filePermissions = $this->driver->getPermissions($file->‪getIdentifier());
776  if ($isReadCheck && !$filePermissions['r']) {
777  return false;
778  }
779  if ($isWriteCheck && !$filePermissions['w']) {
780  return false;
781  }
782  }
783  return true;
784  }
785 
796  public function ‪checkFolderActionPermission($action, ?Folder $folder = null)
797  {
798  // Check 1: Does the user have permission to perform the action? e.g. "writeFolder"
799  if ($this->‪checkUserActionPermission($action, 'Folder') === false) {
800  return false;
801  }
802 
803  // If we do not have a folder here, we cannot do further checks
804  if ($folder === null) {
805  return true;
806  }
807 
808  $isReadCheck = false;
809  if (in_array($action, ['read', 'copy'], true)) {
810  $isReadCheck = true;
811  }
812  $isWriteCheck = false;
813  if (in_array($action, ['add', 'move', 'write', 'delete', 'rename'], true)) {
814  $isWriteCheck = true;
815  }
816  // Check 2: Does the user has the right to perform the action?
817  // (= is he within the file mount borders)
818  if (!$this->‪isWithinFileMountBoundaries($folder, $isWriteCheck)) {
819  return false;
820  }
821  // Check 3: Check the capabilities of the storage (and the driver)
822  if ($isReadCheck && !$this->‪isBrowsable()) {
823  return false;
824  }
825  if ($isWriteCheck && !$this->‪isWritable()) {
826  return false;
827  }
828 
829  // Check 4: "Folder permissions" of the driver
830  $folderPermissions = $this->driver->getPermissions($folder->‪getIdentifier());
831  if ($isReadCheck && !$folderPermissions['r']) {
832  return false;
833  }
834  if ($isWriteCheck && !$folderPermissions['w']) {
835  return false;
836  }
837  return true;
838  }
839 
847  protected function ‪checkFileExtensionPermission($fileName)
848  {
849  $fileName = $this->driver->sanitizeFileName($fileName);
850  return GeneralUtility::makeInstance(FileNameValidator::class)->isValid($fileName);
851  }
852 
857  protected function ‪checkValidFileExtension(FileInterface $file): bool
858  {
859  $fileNameValidator = GeneralUtility::makeInstance(FileNameValidator::class);
860  return $fileNameValidator->isValid($file->getName()) &&
861  $fileNameValidator->isValid(basename($file->getIdentifier()));
862  }
863 
870  protected function ‪assureFolderReadPermission(?Folder $folder = null)
871  {
872  if (!$this->‪checkFolderActionPermission('read', $folder)) {
873  if ($folder === null) {
874  throw new InsufficientFolderAccessPermissionsException(
875  'You are not allowed to read folders',
876  1430657869
877  );
878  }
879  throw new InsufficientFolderAccessPermissionsException(
880  'You are not allowed to access the given folder: "' . $folder->‪getName() . '"',
881  1375955684
882  );
883  }
884  }
885 
895  protected function ‪assureFolderDeletePermission(Folder $folder, $checkDeleteRecursively)
896  {
897  // Check user permissions for recursive deletion if it is requested
898  if ($checkDeleteRecursively && !$this->‪checkUserActionPermission('recursivedelete', 'Folder')) {
899  throw new InsufficientUserPermissionsException('You are not allowed to delete folders recursively', 1377779423);
900  }
901  // Check user action permission
902  if (!$this->‪checkFolderActionPermission('delete', $folder)) {
903  throw new InsufficientFolderAccessPermissionsException(
904  'You are not allowed to delete the given folder: "' . $folder->getName() . '"',
905  1377779039
906  );
907  }
908  // Check if the user has write permissions to folders
909  // Would be good if we could check for actual write permissions in the containing folder
910  // but we cannot since we have no access to the containing folder of this file.
911  if (!$this->‪checkUserActionPermission('write', 'Folder')) {
912  throw new ‪InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377779111);
913  }
914  }
915 
923  protected function ‪assureFileReadPermission(FileInterface $file)
924  {
925  if (!$this->‪checkFileActionPermission('read', $file)) {
926  throw new InsufficientFileAccessPermissionsException(
927  'You are not allowed to access that file: "' . $file->getName() . '"',
928  1375955429
929  );
930  }
931  if (!$this->‪checkValidFileExtension($file)) {
932  throw new IllegalFileExtensionException(
933  'You are not allowed to use that file extension. File: "' . $file->getName() . '"',
934  1375955430
935  );
936  }
937  }
938 
947  protected function ‪assureFileWritePermissions(FileInterface $file)
948  {
949  // Check if user is allowed to write the file and $file is writable
950  if (!$this->‪checkFileActionPermission('write', $file)) {
951  throw new ‪InsufficientFileWritePermissionsException('Writing to file "' . $file->getIdentifier() . '" is not allowed.', 1330121088);
952  }
953  if (!$this->‪checkValidFileExtension($file)) {
954  throw new ‪IllegalFileExtensionException('You are not allowed to edit a file with extension "' . $file->getExtension() . '"', 1366711933);
955  }
956  }
957 
965  protected function ‪assureFileReplacePermissions(FileInterface $file)
966  {
967  // Check if user is allowed to replace the file and $file is writable
968  if (!$this->‪checkFileActionPermission('replace', $file)) {
969  throw new InsufficientFileWritePermissionsException('Replacing file "' . $file->getIdentifier() . '" is not allowed.', 1436899571);
970  }
971  // Check if parentFolder is writable for the user
972  if (!$this->‪checkFolderActionPermission('write', $file->getParentFolder())) {
973  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $file->getIdentifier() . '"', 1436899572);
974  }
975  }
976 
985  protected function ‪assureFileDeletePermissions(FileInterface $file)
986  {
987  // Check for disallowed file extensions
988  if (!$this->‪checkValidFileExtension($file)) {
989  throw new IllegalFileExtensionException('You are not allowed to delete a file with extension "' . $file->getExtension() . '"', 1377778916);
990  }
991  // Check further permissions if file is not a processed file
992  if (!$file instanceof ProcessedFile) {
993  // Check if user is allowed to delete the file and $file is writable
994  if (!$this->‪checkFileActionPermission('delete', $file)) {
995  throw new InsufficientFileWritePermissionsException('You are not allowed to delete the file "' . $file->getIdentifier() . '"', 1319550425);
996  }
997  // Check if the user has write permissions to folders
998  // Would be good if we could check for actual write permissions in the containing folder
999  // but we cannot since we have no access to the containing folder of this file.
1000  if (!$this->‪checkUserActionPermission('write', 'Folder')) {
1001  throw new InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377778702);
1002  }
1003  }
1004  }
1005 
1017  protected function ‪assureFileAddPermissions($targetFolder, $targetFileName)
1018  {
1019  // Check for a valid file extension
1020  if (!$this->‪checkFileExtensionPermission($targetFileName)) {
1021  throw new IllegalFileExtensionException('Extension of file name is not allowed in "' . $targetFileName . '"!', 1322120271);
1022  }
1023  // Makes sure the user is allowed to upload
1024  if (!$this->‪checkUserActionPermission('add', 'File')) {
1025  throw new InsufficientUserPermissionsException('You are not allowed to add files to this storage "' . $this->‪getUid() . '"', 1376992145);
1026  }
1027  // Check if targetFolder is writable
1028  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1029  throw new InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetFolder->getIdentifier() . '"', 1322120356);
1030  }
1031  }
1032 
1048  protected function ‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileSize)
1049  {
1050  // Makes sure this is an uploaded file
1051  if (!is_uploaded_file($localFilePath)) {
1052  throw new UploadException('The upload has failed, no uploaded file found!', 1322110455);
1053  }
1054  // Max upload size (kb) for files.
1055  $maxUploadFileSize = GeneralUtility::getMaxUploadFileSize() * 1024;
1056  if ($maxUploadFileSize > 0 && $uploadedFileSize >= $maxUploadFileSize) {
1057  unlink($localFilePath);
1058  throw new UploadSizeException('The uploaded file exceeds the size-limit of ' . $maxUploadFileSize . ' bytes', 1322110041);
1059  }
1060  $this->‪assureFileAddPermissions($targetFolder, $targetFileName);
1061  }
1062 
1074  protected function ‪assureFileMovePermissions(‪FileInterface $file, ‪Folder $targetFolder, $targetFileName)
1075  {
1076  // Check if targetFolder is within this storage
1077  if ($this->‪getUid() !== $targetFolder->‪getStorage()->‪getUid()) {
1078  throw new \RuntimeException('The target folder is not in the same storage. Target folder given: "' . $targetFolder->‪getIdentifier() . '"', 1422553107);
1079  }
1080  // Check for a valid file extension
1081  if (!$this->‪checkFileExtensionPermission($targetFileName)) {
1082  throw new IllegalFileExtensionException('Extension of file name is not allowed in "' . $targetFileName . '"!', 1378243279);
1083  }
1084  // Check if user is allowed to move and $file is readable and writable
1085  if (!$file->‪getStorage()->‪checkFileActionPermission('move', $file)) {
1086  throw new InsufficientUserPermissionsException('You are not allowed to move files to storage "' . $this->‪getUid() . '"', 1319219349);
1087  }
1088  // Check if target folder is writable
1089  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1090  throw new ‪InsufficientFolderAccessPermissionsException('You are not allowed to write to the target folder "' . $targetFolder->‪getIdentifier() . '"', 1319219350);
1091  }
1092  }
1093 
1104  protected function ‪assureFileRenamePermissions(FileInterface $file, $targetFileName)
1105  {
1106  // Check if file extension is allowed
1107  if (!$this->‪checkFileExtensionPermission($targetFileName) || !$this->‪checkValidFileExtension($file)) {
1108  throw new IllegalFileExtensionException('You are not allowed to rename a file with this extension. File given: "' . $file->getName() . '"', 1371466663);
1109  }
1110  // Check if user is allowed to rename
1111  if (!$this->‪checkFileActionPermission('rename', $file)) {
1112  throw new InsufficientUserPermissionsException('You are not allowed to rename files. File given: "' . $file->getName() . '"', 1319219351);
1113  }
1114  // Check if the user is allowed to write to folders
1115  // Although it would be good to check, we cannot check here if the folder actually is writable
1116  // because we do not know in which folder the file resides.
1117  // So we rely on the driver to throw an exception in case the renaming failed.
1118  if (!$this->‪checkFolderActionPermission('write')) {
1119  throw new InsufficientFileWritePermissionsException('You are not allowed to write to folders', 1319219352);
1120  }
1121  }
1122 
1137  protected function ‪assureFileCopyPermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
1138  {
1139  // Check if targetFolder is within this storage, this should never happen
1140  if ($this->‪getUid() != $targetFolder->getStorage()->getUid()) {
1141  throw new Exception('The operation of the folder cannot be called by this storage "' . $this->‪getUid() . '"', 1319550405);
1142  }
1143  // Check if user is allowed to copy
1144  if (!$file->getStorage()->checkFileActionPermission('copy', $file)) {
1145  throw new InsufficientFileReadPermissionsException('You are not allowed to copy the file "' . $file->getIdentifier() . '"', 1319550426);
1146  }
1147  // Check if targetFolder is writable
1148  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1149  throw new InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetFolder->getIdentifier() . '"', 1319550435);
1150  }
1151  // Check for a valid file extension
1152  if (!$this->‪checkFileExtensionPermission($targetFileName) || !$this->‪checkValidFileExtension($file)) {
1153  throw new IllegalFileExtensionException('You are not allowed to copy a file of that type.', 1319553317);
1154  }
1155  }
1156 
1171  protected function ‪assureFolderCopyPermissions(FolderInterface $folderToCopy, FolderInterface $targetParentFolder)
1172  {
1173  // Check if targetFolder is within this storage, this should never happen
1174  if ($this->‪getUid() !== $targetParentFolder->getStorage()->getUid()) {
1175  throw new Exception('The operation of the folder cannot be called by this storage "' . $this->‪getUid() . '"', 1377777624);
1176  }
1177  if (!$folderToCopy instanceof Folder) {
1178  throw new \RuntimeException('The folder "' . $folderToCopy->getIdentifier() . '" to copy is not of type folder.', 1384209020);
1179  }
1180  // Check if user is allowed to copy and the folder is readable
1181  if (!$folderToCopy->getStorage()->checkFolderActionPermission('copy', $folderToCopy)) {
1182  throw new InsufficientFileReadPermissionsException('You are not allowed to copy the folder "' . $folderToCopy->getIdentifier() . '"', 1377777629);
1183  }
1184  if (!$targetParentFolder instanceof Folder) {
1185  throw new \RuntimeException('The target folder "' . $targetParentFolder->getIdentifier() . '" is not of type folder.', 1384209021);
1186  }
1187  // Check if targetFolder is writable
1188  if (!$this->‪checkFolderActionPermission('write', $targetParentFolder)) {
1189  throw new InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetParentFolder->getIdentifier() . '"', 1377777635);
1190  }
1191  }
1192 
1207  protected function ‪assureFolderMovePermissions(FolderInterface $folderToMove, FolderInterface $targetParentFolder)
1208  {
1209  // Check if targetFolder is within this storage, this should never happen
1210  if ($this->‪getUid() !== $targetParentFolder->getStorage()->getUid()) {
1211  throw new \InvalidArgumentException('Cannot move a folder into a folder that does not belong to this storage.', 1325777289);
1212  }
1213  if (!$folderToMove instanceof Folder) {
1214  throw new \RuntimeException('The folder "' . $folderToMove->getIdentifier() . '" to move is not of type Folder.', 1384209022);
1215  }
1216  // Check if user is allowed to move and the folder is writable
1217  // In fact we would need to check if the parent folder of the folder to move is writable also
1218  // But as of now we cannot extract the parent folder from this folder
1219  if (!$folderToMove->getStorage()->checkFolderActionPermission('move', $folderToMove)) {
1220  throw new InsufficientFileReadPermissionsException('You are not allowed to copy the folder "' . $folderToMove->getIdentifier() . '"', 1377778045);
1221  }
1222  if (!$targetParentFolder instanceof Folder) {
1223  throw new \RuntimeException('The target folder "' . $targetParentFolder->getIdentifier() . '" is not of type Folder.', 1384209023);
1224  }
1225  // Check if targetFolder is writable
1226  if (!$this->‪checkFolderActionPermission('write', $targetParentFolder)) {
1227  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetParentFolder->getIdentifier() . '"', 1377778049);
1228  }
1229  }
1230 
1239  public function ‪sanitizeFileName($fileName, ?Folder $targetFolder = null)
1240  {
1241  $targetFolder = $targetFolder ?: $this->‪getDefaultFolder();
1242  $fileName = $this->driver->sanitizeFileName($fileName);
1243 
1244  // The file name could be changed by an event listener
1245  $fileName = $this->eventDispatcher->dispatch(
1246  new SanitizeFileNameEvent($fileName, $targetFolder, ‪$this, $this->driver)
1247  )->getFileName();
1248 
1249  return $fileName;
1250  }
1251 
1252  /********************
1253  * FILE ACTIONS
1254  ********************/
1268  public function ‪addFile($localFilePath, ‪Folder $targetFolder, $targetFileName = '', $conflictMode = ‪DuplicationBehavior::RENAME, $removeOriginal = true)
1269  {
1270  $localFilePath = ‪PathUtility::getCanonicalPath($localFilePath);
1271  // File is not available locally NOR is it an uploaded file
1272  if (!is_uploaded_file($localFilePath) && !file_exists($localFilePath)) {
1273  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552745);
1274  }
1275  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
1276  $targetFileName = $this->‪sanitizeFileName($targetFileName ?: ‪PathUtility::basename($localFilePath), $targetFolder);
1277 
1278  $targetFileName = $this->eventDispatcher->dispatch(
1279  new ‪BeforeFileAddedEvent($targetFileName, $localFilePath, $targetFolder, ‪$this, $this->driver)
1280  )->getFileName();
1281 
1282  $this->‪assureFileAddPermissions($targetFolder, $targetFileName);
1283 
1284  $replaceExisting = false;
1285  if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && ‪$this->driver->fileExistsInFolder($targetFileName, $targetFolder->‪getIdentifier())) {
1286  throw new ‪ExistingTargetFileNameException('File "' . $targetFileName . '" already exists in folder ' . $targetFolder->‪getIdentifier(), 1322121068);
1287  }
1288  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
1289  $targetFileName = $this->‪getUniqueName($targetFolder, $targetFileName);
1290  } elseif ($conflictMode->equals(‪DuplicationBehavior::REPLACE) && ‪$this->driver->fileExistsInFolder($targetFileName, $targetFolder->‪getIdentifier())) {
1291  $replaceExisting = true;
1292  }
1293 
1294  $fileIdentifier = $this->driver->addFile($localFilePath, $targetFolder->‪getIdentifier(), $targetFileName, $removeOriginal);
1295  $file = $this->‪getFileByIdentifier($fileIdentifier);
1296 
1297  if ($replaceExisting && $file instanceof ‪File) {
1298  $this->‪getIndexer()->‪updateIndexEntry($file);
1299  }
1300 
1301  $this->eventDispatcher->dispatch(
1302  new ‪AfterFileAddedEvent($file, $targetFolder)
1303  );
1304  return $file;
1305  }
1306 
1317  public function ‪updateProcessedFile($localFilePath, ‪ProcessedFile $processedFile, ?‪Folder ‪$processingFolder = null)
1318  {
1319  if (!file_exists($localFilePath)) {
1320  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552746);
1321  }
1322  if (‪$processingFolder === null) {
1324  }
1325  $fileIdentifier = $this->driver->addFile($localFilePath, ‪$processingFolder->‪getIdentifier(), $processedFile->‪getName());
1326  // @todo check if we have to update the processed file other then the identifier
1327  $processedFile->‪setIdentifier($fileIdentifier);
1328  return $processedFile;
1329  }
1330 
1339  public function ‪hashFile(‪FileInterface $fileObject, $hash)
1340  {
1341  return $this->‪hashFileByIdentifier($fileObject->‪getIdentifier(), $hash);
1342  }
1343 
1352  public function ‪hashFileByIdentifier($fileIdentifier, $hash)
1353  {
1354  $hash = $this->driver->hash($fileIdentifier, $hash);
1355  if (!is_string($hash) || $hash === '') {
1356  throw new ‪InvalidHashException('Hash has to be non-empty string.', 1551950301);
1357  }
1358  return $hash;
1359  }
1360 
1369  public function ‪hashFileIdentifier($file)
1370  {
1371  if (is_object($file) && $file instanceof FileInterface) {
1373  $file = $file->getIdentifier();
1374  }
1375  return $this->driver->hashIdentifier($file);
1376  }
1377 
1388  public function ‪getPublicUrl(ResourceInterface $resourceObject, $relativeToCurrentScript = false)
1389  {
1390  if ($relativeToCurrentScript !== false) {
1391  trigger_error('FAL API usage with "getPublicUrl" returning a relative path will be removed in TYPO3 v12.0.', E_USER_DEPRECATED);
1392  }
1393  $publicUrl = null;
1394  if ($this->‪isOnline()) {
1395  // Pre-process the public URL by an accordant event
1396  $event = new GeneratePublicUrlForResourceEvent($resourceObject, ‪$this, $this->driver, $relativeToCurrentScript);
1397  $publicUrl = $this->eventDispatcher->dispatch($event)->getPublicUrl();
1398  if (
1399  $publicUrl === null
1400  && $resourceObject instanceof File
1401  && ($helper = GeneralUtility::makeInstance(OnlineMediaHelperRegistry::class)->getOnlineMediaHelper($resourceObject)) !== false
1402  ) {
1403  $publicUrl = $helper->getPublicUrl($resourceObject, $relativeToCurrentScript);
1404  }
1405 
1406  // If an event listener did not handle the URL generation, use the default way to determine public URL
1407  if ($publicUrl === null) {
1408  if ($this->‪hasCapability(self::CAPABILITY_PUBLIC)) {
1409  $publicUrl = $this->driver->getPublicUrl($resourceObject->getIdentifier());
1410  }
1411 
1412  if ($publicUrl === null && $resourceObject instanceof FileInterface) {
1413  $queryParameterArray = ['eID' => 'dumpFile', 't' => ''];
1414  if ($resourceObject instanceof File) {
1415  $queryParameterArray['f'] = $resourceObject->getUid();
1416  $queryParameterArray['t'] = 'f';
1417  } elseif ($resourceObject instanceof ProcessedFile) {
1418  $queryParameterArray['p'] = $resourceObject->getUid();
1419  $queryParameterArray['t'] = 'p';
1420  }
1421 
1422  $queryParameterArray['token'] = GeneralUtility::hmac(implode('|', $queryParameterArray), 'resourceStorageDumpFile');
1423  $publicUrl = GeneralUtility::locationHeaderUrl(‪PathUtility::getAbsoluteWebPath(‪Environment::getPublicPath() . '/index.php'));
1424  $publicUrl .= '?' . http_build_query($queryParameterArray, '', '&', PHP_QUERY_RFC3986);
1425  }
1426 
1427  // If requested, make the path relative to the current script in order to make it possible
1428  // to use the relative file
1429  if ($publicUrl !== null && $relativeToCurrentScript && !‪GeneralUtility::isValidUrl($publicUrl)) {
1430  $absolutePathToContainingFolder = ‪PathUtility::dirname(‪Environment::getPublicPath() . '/' . $publicUrl);
1431  $pathPart = ‪PathUtility::getRelativePathTo($absolutePathToContainingFolder);
1432  $filePart = substr(‪Environment::getPublicPath() . '/' . $publicUrl, strlen($absolutePathToContainingFolder) + 1);
1433  $publicUrl = $pathPart . $filePart;
1434  }
1435  }
1436  }
1437  return $publicUrl;
1438  }
1439 
1450  public function ‪processFile(FileInterface $fileObject, $context, array ‪$configuration)
1451  {
1452  if ($fileObject->getStorage() !== ‪$this) {
1453  throw new \InvalidArgumentException('Cannot process files of foreign storage', 1353401835);
1454  }
1455  $processedFile = $this->‪getFileProcessingService()->‪processFile($fileObject, ‪$this, $context, ‪$configuration);
1456 
1457  return $processedFile;
1458  }
1459 
1467  public function ‪getFileForLocalProcessing(FileInterface $fileObject, $writable = true)
1468  {
1469  $filePath = $this->driver->getFileForLocalProcessing($fileObject->getIdentifier(), $writable);
1470  return $filePath;
1471  }
1472 
1479  public function ‪getFile($identifier)
1480  {
1481  $file = $this->‪getFileByIdentifier($identifier);
1482  if (!$this->driver->fileExists($identifier)) {
1483  $file->setMissing(true);
1484  }
1485  return $file;
1486  }
1487 
1496  public function ‪getFileByIdentifier(string $fileIdentifier)
1497  {
1498  if (!$this->‪isWithinProcessingFolder($fileIdentifier)) {
1499  $fileData = $this->‪getFileIndexRepository()->‪findOneByStorageAndIdentifier(‪$this, $fileIdentifier);
1500  if ($fileData === false) {
1501  return $this->‪getIndexer()->‪createIndexEntry($fileIdentifier);
1502  }
1503  return $this->‪getResourceFactoryInstance()->‪getFileObject($fileData['uid'], $fileData);
1504  }
1505  return $this->‪getProcessedFileRepository()->findByStorageAndIdentifier(‪$this, $fileIdentifier);
1506  }
1507 
1509  {
1510  return GeneralUtility::makeInstance(ProcessedFileRepository::class);
1511  }
1512 
1520  public function ‪getFileInfo(FileInterface $fileObject)
1521  {
1522  return $this->‪getFileInfoByIdentifier($fileObject->getIdentifier());
1523  }
1524 
1533  public function ‪getFileInfoByIdentifier($identifier, array $propertiesToExtract = [])
1534  {
1535  return $this->driver->getFileInfoByIdentifier($identifier, $propertiesToExtract);
1536  }
1537 
1541  public function ‪unsetFileAndFolderNameFilters()
1542  {
1543  $this->‪fileAndFolderNameFilters = [];
1544  }
1545 
1550  {
1551  $this->‪fileAndFolderNameFilters = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['defaultFilterCallbacks'];
1552  }
1553 
1560  public function getImportExportFilter(): array
1561  {
1562  $filter = GeneralUtility::makeInstance(ImportExportFilter::class);
1563 
1564  return [$filter, 'filterImportExportFilesAndFolders'];
1565  }
1566 
1572  public function ‪getFileAndFolderNameFilters()
1573  {
1574  return array_merge($this->‪fileAndFolderNameFilters, [$this->getImportExportFilter()]);
1575  }
1581  public function setFileAndFolderNameFilters(array $filters)
1582  {
1583  $this->‪fileAndFolderNameFilters = $filters;
1584  return ‪$this;
1585  }
1590  public function ‪addFileAndFolderNameFilter($filter)
1591  {
1592  $this->‪fileAndFolderNameFilters[] = $filter;
1593  }
1594 
1600  public function ‪getFolderIdentifierFromFileIdentifier($fileIdentifier)
1601  {
1602  return $this->driver->getParentFolderIdentifierOfIdentifier($fileIdentifier);
1603  }
1604 
1612  public function ‪getFileInFolder($fileName, Folder $folder)
1613  {
1614  $identifier = $this->driver->getFileInFolder($fileName, $folder->getIdentifier());
1615  return $this->‪getFileByIdentifier($identifier);
1616  }
1617 
1633  public function ‪getFilesInFolder(Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
1634  {
1635  $this->‪assureFolderReadPermission($folder);
1636 
1637  $rows = $this->‪getFileIndexRepository()->‪findByFolder($folder);
1638 
1639  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
1640  $fileIdentifiers = array_values($this->driver->getFilesInFolder($folder->getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev));
1641 
1642  $items = [];
1643  foreach ($fileIdentifiers as $identifier) {
1644  if (isset($rows[$identifier])) {
1645  $fileObject = $this->‪getFileFactory()->‪getFileObject($rows[$identifier]['uid'], $rows[$identifier]);
1646  } else {
1647  $fileObject = $this->‪getFileByIdentifier($identifier);
1648  }
1649  if ($fileObject instanceof FileInterface) {
1650  $key = $fileObject->getName();
1651  while (isset($items[$key])) {
1652  $key .= 'z';
1653  }
1654  $items[$key] = $fileObject;
1655  }
1656  }
1657 
1658  return $items;
1659  }
1660 
1667  public function ‪getFileIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
1668  {
1669  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
1670  return $this->driver->getFilesInFolder($folderIdentifier, 0, 0, $recursive, $filters);
1671  }
1672 
1680  public function ‪countFilesInFolder(Folder $folder, $useFilters = true, $recursive = false)
1681  {
1682  $this->‪assureFolderReadPermission($folder);
1683  $filters = $useFilters ? $this->‪getFileAndFolderNameFilters() : [];
1684  return $this->driver->countFilesInFolder($folder->getIdentifier(), $recursive, $filters);
1685  }
1686 
1693  public function ‪getFolderIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
1694  {
1695  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
1696  return $this->driver->getFoldersInFolder($folderIdentifier, 0, 0, $recursive, $filters);
1697  }
1698 
1705  public function ‪hasFile($identifier)
1706  {
1707  // Allow if identifier is in processing folder
1708  if (!$this->‪isWithinProcessingFolder($identifier)) {
1710  }
1711  return $this->driver->fileExists($identifier);
1712  }
1713 
1719  public function ‪getProcessingFolders()
1720  {
1721  if ($this->processingFolders === null) {
1722  $this->processingFolders = [];
1723  $this->processingFolders[] = $this->‪getProcessingFolder();
1724  $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
1725  $allStorages = $storageRepository->findAll();
1726  foreach ($allStorages as $storage) {
1727  // To circumvent the permission check of the folder, we use the factory to create it "manually" instead of directly using $storage->getProcessingFolder()
1728  // See #66695 for details
1729  [$storageUid, $processingFolderIdentifier] = array_pad(‪GeneralUtility::trimExplode(':', $storage->getStorageRecord()['processingfolder']), 2, null);
1730  if (empty($processingFolderIdentifier) || (int)$storageUid !== $this->‪getUid()) {
1731  continue;
1732  }
1733  $potentialProcessingFolder = $this->‪createFolderObject($processingFolderIdentifier, $processingFolderIdentifier);
1734  if ($potentialProcessingFolder->getStorage() === ‪$this && $potentialProcessingFolder->getIdentifier() !== ‪$this->getProcessingFolder()->getIdentifier()) {
1735  $this->processingFolders[] = $potentialProcessingFolder;
1736  }
1737  }
1738  }
1739 
1741  }
1742 
1750  public function ‪isProcessingFolder(Folder $folder)
1751  {
1752  $isProcessingFolder = false;
1753  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
1754  if ($folder->getCombinedIdentifier() === ‪$processingFolder->‪getCombinedIdentifier()) {
1755  $isProcessingFolder = true;
1756  break;
1757  }
1758  }
1759  return $isProcessingFolder;
1760  }
1761 
1769  public function ‪hasFileInFolder($fileName, ‪Folder $folder)
1770  {
1771  $this->‪assureFolderReadPermission($folder);
1772  return $this->driver->fileExistsInFolder($fileName, $folder->‪getIdentifier());
1773  }
1774 
1783  public function ‪getFileContents($file)
1784  {
1785  $this->‪assureFileReadPermission($file);
1786  return $this->driver->getFileContents($file->getIdentifier());
1787  }
1788 
1798  public function ‪streamFile(
1799  ‪FileInterface $file,
1800  bool $asDownload = false,
1801  ?string $alternativeFilename = null,
1802  ?string $overrideMimeType = null
1803  ): ResponseInterface {
1804  $this->‪assureFileReadPermission($file);
1805  if (!$this->driver instanceof ‪StreamableDriverInterface) {
1806  return $this->‪getPseudoStream($file, $asDownload, $alternativeFilename, $overrideMimeType);
1807  }
1808 
1809  $properties = [
1810  'as_download' => $asDownload,
1811  'filename_overwrite' => $alternativeFilename,
1812  'mimetype_overwrite' => $overrideMimeType,
1813  ];
1814  return $this->driver->streamFile($file->‪getIdentifier(), $properties);
1815  }
1816 
1826  protected function ‪getPseudoStream(
1827  ‪FileInterface $file,
1828  bool $asDownload = false,
1829  ?string $alternativeFilename = null,
1830  ?string $overrideMimeType = null
1831  ) {
1832  $downloadName = $alternativeFilename ?: $file->‪getName();
1833  $contentDisposition = $asDownload ? 'attachment' : 'inline';
1834 
1835  $stream = new ‪FalDumpFileContentsDecoratorStream($file->‪getIdentifier(), ‪$this->driver, $file->‪getSize());
1836  $fileInfo = $this->driver->getFileInfoByIdentifier($file->‪getIdentifier(), ['mtime']);
1837  $headers = [
1838  'Content-Disposition' => $contentDisposition . '; filename="' . $downloadName . '"',
1839  'Content-Type' => $overrideMimeType ?: $file->‪getMimeType(),
1840  'Content-Length' => (string)$file->‪getSize(),
1841  'Last-Modified' => gmdate('D, d M Y H:i:s', array_pop($fileInfo)) . ' GMT',
1842  // Cache-Control header is needed here to solve an issue with browser IE8 and lower
1843  // See for more information: http://support.microsoft.com/kb/323308
1844  'Cache-Control' => '',
1845  ];
1846 
1847  return new ‪Response($stream, 200, $headers);
1848  }
1849 
1861  public function ‪setFileContents(‪AbstractFile $file, $contents)
1862  {
1863  // Check if user is allowed to edit
1864  $this->‪assureFileWritePermissions($file);
1865  $this->eventDispatcher->dispatch(
1866  new ‪BeforeFileContentsSetEvent($file, $contents)
1867  );
1868  // Call driver method to update the file and update file index entry afterwards
1869  $result = $this->driver->setFileContents($file->‪getIdentifier(), $contents);
1870  if ($file instanceof ‪File) {
1871  $this->‪getIndexer()->‪updateIndexEntry($file);
1872  }
1873  $this->eventDispatcher->dispatch(
1874  new AfterFileContentsSetEvent($file, $contents)
1875  );
1876  return $result;
1877  }
1878 
1891  public function ‪createFile($fileName, ‪Folder $targetFolderObject)
1892  {
1893  $this->‪assureFileAddPermissions($targetFolderObject, $fileName);
1894  $this->eventDispatcher->dispatch(
1895  new ‪BeforeFileCreatedEvent($fileName, $targetFolderObject)
1896  );
1897  $newFileIdentifier = $this->driver->createFile($fileName, $targetFolderObject->‪getIdentifier());
1898  $this->eventDispatcher->dispatch(
1899  new ‪AfterFileCreatedEvent($newFileIdentifier, $targetFolderObject)
1900  );
1901  return $this->‪getFileByIdentifier($newFileIdentifier);
1902  }
1903 
1912  public function ‪deleteFile($fileObject)
1913  {
1914  $this->‪assureFileDeletePermissions($fileObject);
1915 
1916  $this->eventDispatcher->dispatch(
1917  new ‪BeforeFileDeletedEvent($fileObject)
1918  );
1919  $deleted = true;
1920 
1921  if ($this->driver->fileExists($fileObject->getIdentifier())) {
1922  // Disable permission check to find nearest recycler and move file without errors
1923  $currentPermissions = ‪$this->evaluatePermissions;
1924  $this->evaluatePermissions = false;
1925 
1926  $recyclerFolder = $this->‪getNearestRecyclerFolder($fileObject);
1927  if ($recyclerFolder === null) {
1928  $result = $this->driver->deleteFile($fileObject->getIdentifier());
1929  } else {
1930  $result = $this->‪moveFile($fileObject, $recyclerFolder);
1931  $deleted = false;
1932  }
1933 
1934  $this->evaluatePermissions = $currentPermissions;
1935 
1936  if (!$result) {
1937  throw new FileOperationErrorException('Deleting the file "' . $fileObject->getIdentifier() . '\' failed.', 1329831691);
1938  }
1939  }
1940  // Mark the file object as deleted
1941  if ($deleted && $fileObject instanceof AbstractFile) {
1942  $fileObject->setDeleted();
1943  }
1944 
1945  $this->eventDispatcher->dispatch(
1946  new AfterFileDeletedEvent($fileObject)
1947  );
1948 
1949  return true;
1950  }
1951 
1966  public function copyFile(FileInterface $file, Folder $targetFolder, $targetFileName = null, $conflictMode = DuplicationBehavior::RENAME)
1967  {
1968  $conflictMode = DuplicationBehavior::cast($conflictMode);
1969  if ($targetFileName === null) {
1970  $targetFileName = $file->getName();
1971  }
1972  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
1973  $this->assureFileCopyPermissions($file, $targetFolder, $sanitizedTargetFileName);
1974 
1975  $this->eventDispatcher->dispatch(
1976  new BeforeFileCopiedEvent($file, $targetFolder)
1977  );
1978 
1979  // File exists and we should abort, let's abort
1980  ‪if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && $targetFolder->hasFile($sanitizedTargetFileName)) {
1981  throw new ExistingTargetFileNameException('The target file already exists.', 1320291064);
1982  }
1983  // File exists and we should find another name, let's find another one
1984  ‪if ($conflictMode->equals(‪DuplicationBehavior::RENAME) && $targetFolder->hasFile($sanitizedTargetFileName)) {
1985  $sanitizedTargetFileName = $this->getUniqueName($targetFolder, $sanitizedTargetFileName);
1986  }
1987  $sourceStorage = $file->‪getStorage();
1988  // Call driver method to create a new file from an existing file object,
1989  // and return the new file object
1990  ‪if ($sourceStorage === ‪$this) {
1991  $newFileObjectIdentifier = $this->driver->copyFileWithinStorage($file->‪getIdentifier(), $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1992  } else {
1993  $tempPath = $file->‪getForLocalProcessing();
1994  $newFileObjectIdentifier = $this->driver->addFile($tempPath, $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1995  }
1996  $newFileObject = $this->‪getFileByIdentifier($newFileObjectIdentifier);
1997 
1998  // In case we deal with a file, also copy corresponding metadata
1999  if ($file instanceof File && $newFileObject !== null) {
2000  $metaDataAspect = $newFileObject->getMetaData();
2001  // Add meta data of file while keeping existing properties like "file", "uid", etc.
2002  $metaDataAspect->add(array_replace($file->getMetaData()->get(), $metaDataAspect->get()));
2003  $metaDataAspect->save();
2004  }
2005 
2006  $this->eventDispatcher->dispatch(
2007  new AfterFileCopiedEvent($file, $targetFolder, $newFileObjectIdentifier, $newFileObject)
2008  );
2009  return $newFileObject;
2010  }
2011 
2027  public function ‪moveFile($file, $targetFolder, $targetFileName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2028  {
2029  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2030  if ($targetFileName === null) {
2031  $targetFileName = $file->‪getName();
2032  }
2033  $originalFolder = $file->‪getParentFolder();
2034  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
2035  $this->‪assureFileMovePermissions($file, $targetFolder, $sanitizedTargetFileName);
2036  if ($targetFolder->hasFile($sanitizedTargetFileName)) {
2037  // File exists and we should abort, let's abort
2038  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
2039  $sanitizedTargetFileName = $this->‪getUniqueName($targetFolder, $sanitizedTargetFileName);
2040  } elseif ($conflictMode->equals(‪DuplicationBehavior::CANCEL)) {
2041  throw new ExistingTargetFileNameException('The target file already exists', 1329850997);
2042  }
2043  }
2044  $this->eventDispatcher->dispatch(
2045  new BeforeFileMovedEvent($file, $targetFolder, $sanitizedTargetFileName)
2046  );
2047  $sourceStorage = $file->‪getStorage();
2048  // Call driver method to move the file and update the index entry
2049  try {
2050  if ($sourceStorage === ‪$this) {
2051  $newIdentifier = $this->driver->moveFileWithinStorage($file->‪getIdentifier(), $targetFolder->getIdentifier(), $sanitizedTargetFileName);
2052  if (!$file instanceof AbstractFile) {
2053  throw new \RuntimeException('The given file is not of type AbstractFile.', 1384209025);
2054  }
2055  $file->‪updateProperties(['identifier' => $newIdentifier]);
2056  } else {
2057  $tempPath = $file->‪getForLocalProcessing();
2058  $newIdentifier = $this->driver->addFile($tempPath, $targetFolder->getIdentifier(), $sanitizedTargetFileName);
2059 
2060  // Disable permission check to find nearest recycler and move file without errors
2061  $currentPermissions = $sourceStorage->evaluatePermissions;
2062  $sourceStorage->evaluatePermissions = false;
2063 
2064  $recyclerFolder = $sourceStorage->getNearestRecyclerFolder($file);
2065  if ($recyclerFolder === null) {
2066  $sourceStorage->driver->deleteFile($file->‪getIdentifier());
2067  } else {
2068  $sourceStorage->moveFile($file, $recyclerFolder);
2069  }
2070  $sourceStorage->evaluatePermissions = $currentPermissions;
2071  if ($file instanceof File) {
2072  $file->‪updateProperties(['storage' => $this->‪getUid(), 'identifier' => $newIdentifier]);
2073  }
2074  }
2075  $this->‪getIndexer()->‪updateIndexEntry($file);
2076  } catch (\‪TYPO3\CMS\Core\Exception $e) {
2077  echo $e->getMessage();
2078  }
2079  $this->eventDispatcher->dispatch(
2080  new ‪AfterFileMovedEvent($file, $targetFolder, $originalFolder)
2081  );
2082  return $file;
2083  }
2084 
2094  public function ‪renameFile($file, $targetFileName, $conflictMode = ‪DuplicationBehavior::RENAME)
2095  {
2096  // The name should be different from the current.
2097  if ($file->‪getName() === $targetFileName) {
2098  return $file;
2099  }
2100  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
2101  $this->‪assureFileRenamePermissions($file, $sanitizedTargetFileName);
2102  $this->eventDispatcher->dispatch(
2103  new BeforeFileRenamedEvent($file, $sanitizedTargetFileName)
2104  );
2105 
2106  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2107 
2108  // Call driver method to rename the file and update the index entry
2109  try {
2110  $newIdentifier = $this->driver->renameFile($file->‪getIdentifier(), $sanitizedTargetFileName);
2111  if ($file instanceof File) {
2112  $file->‪updateProperties(['identifier' => $newIdentifier]);
2113  }
2114  $this->‪getIndexer()->‪updateIndexEntry($file);
2115  } catch (ExistingTargetFileNameException $exception) {
2116  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
2117  $newName = $this->‪getUniqueName($file->‪getParentFolder(), $sanitizedTargetFileName);
2118  $file = $this->‪renameFile($file, $newName);
2119  } elseif ($conflictMode->equals(‪DuplicationBehavior::CANCEL)) {
2120  throw $exception;
2121  } elseif ($conflictMode->equals(‪DuplicationBehavior::REPLACE)) {
2122  $sourceFileIdentifier = substr($file->‪getCombinedIdentifier(), 0, (int)strrpos($file->‪getCombinedIdentifier(), '/') + 1) . $sanitizedTargetFileName;
2123  $sourceFile = $this->‪getResourceFactoryInstance()->‪getFileObjectFromCombinedIdentifier($sourceFileIdentifier);
2124  $file = $this->‪replaceFile($sourceFile, ‪Environment::getPublicPath() . '/' . $file->‪getPublicUrl());
2125  }
2126  } catch (\RuntimeException $e) {
2127  }
2128 
2129  $this->eventDispatcher->dispatch(
2130  new AfterFileRenamedEvent($file, $sanitizedTargetFileName)
2131  );
2132 
2133  return $file;
2134  }
2135 
2147  public function ‪replaceFile(‪FileInterface $file, $localFilePath)
2148  {
2149  $this->‪assureFileReplacePermissions($file);
2150  if (!file_exists($localFilePath)) {
2151  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1325842622);
2152  }
2153  $this->eventDispatcher->dispatch(
2154  new BeforeFileReplacedEvent($file, $localFilePath)
2155  );
2156  $this->driver->replaceFile($file->‪getIdentifier(), $localFilePath);
2157  if ($file instanceof File) {
2158  $this->‪getIndexer()->‪updateIndexEntry($file);
2159  }
2160  $this->eventDispatcher->dispatch(
2161  new ‪AfterFileReplacedEvent($file, $localFilePath)
2162  );
2163  return $file;
2164  }
2165 
2175  public function ‪addUploadedFile(array $uploadedFileData, ?‪Folder $targetFolder = null, $targetFileName = null, $conflictMode = ‪DuplicationBehavior::CANCEL)
2176  {
2177  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2178  $localFilePath = $uploadedFileData['tmp_name'];
2179  if ($targetFolder === null) {
2180  $targetFolder = $this->‪getDefaultFolder();
2181  }
2182  if ($targetFileName === null) {
2183  $targetFileName = \Normalizer::normalize($uploadedFileData['name']);
2184  }
2185  $targetFileName = $this->driver->sanitizeFileName($targetFileName);
2186 
2187  $this->‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileData['size']);
2188  if ($this->‪hasFileInFolder($targetFileName, $targetFolder) && $conflictMode->equals(‪DuplicationBehavior::REPLACE)) {
2189  $file = $this->‪getFileInFolder($targetFileName, $targetFolder);
2190  $resultObject = $this->‪replaceFile($file, $localFilePath);
2191  } else {
2192  $resultObject = $this->‪addFile($localFilePath, $targetFolder, $targetFileName, (string)$conflictMode);
2193  }
2194  return $resultObject;
2195  }
2196 
2197  /********************
2198  * FOLDER ACTIONS
2199  ********************/
2206  protected function ‪getAllFileObjectsInFolder(Folder $folder)
2207  {
2208  $files = [];
2209  $folderQueue = [$folder];
2210  while (!empty($folderQueue)) {
2211  $folder = array_shift($folderQueue);
2212  foreach ($folder->getSubfolders() as $subfolder) {
2213  $folderQueue[] = $subfolder;
2214  }
2215  foreach ($folder->getFiles() as $file) {
2217  $files[$file->getIdentifier()] = $file;
2218  }
2219  }
2220 
2221  return $files;
2222  }
2223 
2238  public function ‪moveFolder(Folder $folderToMove, Folder $targetParentFolder, $newFolderName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2239  {
2240  // @todo add tests
2241  $this->‪assureFolderMovePermissions($folderToMove, $targetParentFolder);
2242  $sourceStorage = $folderToMove->getStorage();
2243  $sanitizedNewFolderName = $this->driver->sanitizeFileName($newFolderName ?: $folderToMove->getName());
2244  // @todo check if folder already exists in $targetParentFolder, handle this conflict then
2245  $this->eventDispatcher->dispatch(
2246  new BeforeFolderMovedEvent($folderToMove, $targetParentFolder, $sanitizedNewFolderName)
2247  );
2248  // Get all file objects now so we are able to update them after moving the folder
2249  $fileObjects = $this->‪getAllFileObjectsInFolder($folderToMove);
2250  if ($sourceStorage === ‪$this) {
2251  if ($this->‪isWithinFolder($folderToMove, $targetParentFolder)) {
2252  throw new InvalidTargetFolderException(
2253  sprintf(
2254  'Cannot move folder "%s" into target folder "%s", because the target folder is already within the folder to be moved!',
2255  $folderToMove->getName(),
2256  $targetParentFolder->getName()
2257  ),
2258  1422723050
2259  );
2260  }
2261  $fileMappings = $this->driver->moveFolderWithinStorage($folderToMove->getIdentifier(), $targetParentFolder->getIdentifier(), $sanitizedNewFolderName);
2262  } else {
2263  $fileMappings = $this->‪moveFolderBetweenStorages($folderToMove, $targetParentFolder, $sanitizedNewFolderName);
2264  }
2265  // Update the identifier and storage of all file objects
2266  foreach ($fileObjects as $oldIdentifier => $fileObject) {
2267  $newIdentifier = $fileMappings[$oldIdentifier];
2268  $fileObject->updateProperties(['storage' => $this->‪getUid(), 'identifier' => $newIdentifier]);
2269  $this->‪getIndexer()->‪updateIndexEntry($fileObject);
2270  }
2271  $returnObject = $this->‪getFolder($fileMappings[$folderToMove->getIdentifier()]);
2272 
2273  $this->eventDispatcher->dispatch(
2274  new ‪AfterFolderMovedEvent($folderToMove, $targetParentFolder, $returnObject)
2275  );
2276  return $returnObject;
2277  }
2278 
2287  protected function ‪moveFolderBetweenStorages(‪Folder $folderToMove, ‪Folder $targetParentFolder, $newFolderName)
2288  {
2289  throw new ‪NotImplementedMethodException('Not yet implemented', 1476046361);
2290  }
2291 
2302  public function ‪copyFolder(‪FolderInterface $folderToCopy, ‪FolderInterface $targetParentFolder, $newFolderName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2303  {
2304  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2305  $this->‪assureFolderCopyPermissions($folderToCopy, $targetParentFolder);
2306  $returnObject = null;
2307  $sanitizedNewFolderName = $this->driver->sanitizeFileName($newFolderName ?: $folderToCopy->‪getName());
2308  if ($folderToCopy instanceof ‪Folder && $targetParentFolder instanceof ‪Folder) {
2309  $this->eventDispatcher->dispatch(
2310  new ‪BeforeFolderCopiedEvent($folderToCopy, $targetParentFolder, $sanitizedNewFolderName)
2311  );
2312  }
2313  if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && ($targetParentFolder->hasFolder($sanitizedNewFolderName) || $targetParentFolder->hasFile($sanitizedNewFolderName))) {
2314  throw new InvalidTargetFolderException(
2315  sprintf(
2316  'Cannot copy folder "%s" into target folder "%s", because there is already a folder or file with that name in the target folder!',
2317  $sanitizedNewFolderName,
2318  $targetParentFolder->‪getIdentifier()
2319  ),
2320  1422723059
2321  );
2322  }
2323  // Folder exists and we should find another name, let's find another one
2324  if ($conflictMode->equals(‪DuplicationBehavior::RENAME) && ($targetParentFolder->hasFolder($sanitizedNewFolderName) || $targetParentFolder->hasFile($sanitizedNewFolderName))) {
2325  $sanitizedNewFolderName = $this->‪getUniqueName($targetParentFolder, $sanitizedNewFolderName);
2326  }
2327  $sourceStorage = $folderToCopy->‪getStorage();
2328  // call driver method to move the file
2329  // that also updates the file object properties
2330  if ($sourceStorage === ‪$this) {
2331  $this->driver->copyFolderWithinStorage($folderToCopy->‪getIdentifier(), $targetParentFolder->‪getIdentifier(), $sanitizedNewFolderName);
2332  $returnObject = $this->‪getFolder($targetParentFolder->getSubfolder($sanitizedNewFolderName)->‪getIdentifier());
2333  } else {
2334  $this->‪copyFolderBetweenStorages($folderToCopy, $targetParentFolder, $sanitizedNewFolderName);
2335  }
2336  if ($folderToCopy instanceof Folder && $targetParentFolder instanceof Folder) {
2337  $this->eventDispatcher->dispatch(
2338  new ‪AfterFolderCopiedEvent($folderToCopy, $targetParentFolder, $returnObject)
2339  );
2340  }
2341  return $returnObject;
2342  }
2343 
2352  protected function ‪copyFolderBetweenStorages(‪FolderInterface $folderToCopy, ‪FolderInterface $targetParentFolder, $newFolderName)
2353  {
2354  throw new ‪NotImplementedMethodException('Not yet implemented.', 1476046386);
2355  }
2356 
2366  public function ‪renameFolder($folderObject, $newName)
2367  {
2368  // Renaming the folder should check if the parent folder is writable
2369  // We cannot do this however because we cannot extract the parent folder from a folder currently
2370  if (!$this->‪checkFolderActionPermission('rename', $folderObject)) {
2371  throw new ‪InsufficientUserPermissionsException('You are not allowed to rename the folder "' . $folderObject->getIdentifier() . '\'', 1357811441);
2372  }
2373 
2374  $sanitizedNewName = $this->driver->sanitizeFileName($newName);
2375  if ($this->driver->folderExistsInFolder($sanitizedNewName, $folderObject->getIdentifier())) {
2376  throw new \InvalidArgumentException('The folder ' . $sanitizedNewName . ' already exists in folder ' . $folderObject->getIdentifier(), 1325418870);
2377  }
2378  $this->eventDispatcher->dispatch(
2379  new BeforeFolderRenamedEvent($folderObject, $sanitizedNewName)
2380  );
2381  $fileObjects = $this->‪getAllFileObjectsInFolder($folderObject);
2382  $fileMappings = $this->driver->renameFolder($folderObject->getIdentifier(), $sanitizedNewName);
2383  // Update the identifier of all file objects
2384  foreach ($fileObjects as $oldIdentifier => $fileObject) {
2385  $newIdentifier = $fileMappings[$oldIdentifier];
2386  $fileObject->updateProperties(['identifier' => $newIdentifier]);
2387  $this->‪getIndexer()->‪updateIndexEntry($fileObject);
2388  }
2389  $returnObject = $this->‪getFolder($fileMappings[$folderObject->getIdentifier()]);
2390 
2391  $this->eventDispatcher->dispatch(
2392  new AfterFolderRenamedEvent($returnObject, $folderObject)
2393  );
2394  return $returnObject;
2395  }
2396 
2409  public function ‪deleteFolder($folderObject, $deleteRecursively = false)
2410  {
2411  $isEmpty = $this->driver->isFolderEmpty($folderObject->getIdentifier());
2412  $this->‪assureFolderDeletePermission($folderObject, $deleteRecursively && !$isEmpty);
2413  if (!$isEmpty && !$deleteRecursively) {
2414  throw new \RuntimeException('Could not delete folder "' . $folderObject->getIdentifier() . '" because it is not empty.', 1325952534);
2415  }
2416 
2417  $this->eventDispatcher->dispatch(
2418  new BeforeFolderDeletedEvent($folderObject)
2419  );
2420 
2421  foreach ($this->‪getFilesInFolder($folderObject, 0, 0, false, $deleteRecursively) as $file) {
2422  $this->‪deleteFile($file);
2423  }
2424 
2425  $result = $this->driver->deleteFolder($folderObject->getIdentifier(), $deleteRecursively);
2426 
2427  $this->eventDispatcher->dispatch(
2428  new AfterFolderDeletedEvent($folderObject, $result)
2429  );
2430  return $result;
2431  }
2432 
2443  public function ‪getFolderInFolder($folderName, ‪Folder $parentFolder, $returnInaccessibleFolderObject = false)
2444  {
2445  $folderIdentifier = $this->driver->getFolderInFolder($folderName, $parentFolder->‪getIdentifier());
2446  return $this->‪getFolder($folderIdentifier, $returnInaccessibleFolderObject);
2447  }
2448 
2463  public function getFoldersInFolder(‪Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
2464  {
2465  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
2466 
2467  ‪$folderIdentifiers = $this->driver->getFoldersInFolder($folder->‪getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev);
2469  // Exclude processing folders
2470  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
2471  $processingIdentifier = ‪$processingFolder->‪getIdentifier();
2472  if (isset(‪$folderIdentifiers[$processingIdentifier])) {
2473  unset(‪$folderIdentifiers[$processingIdentifier]);
2474  }
2475  }
2476 
2477  ‪$folders = [];
2478  foreach (‪$folderIdentifiers as $folderIdentifier) {
2479  // The folder identifier can also be an int-like string, resulting in int array keys.
2480  ‪$folders[$folderIdentifier] = $this->‪getFolder($folderIdentifier, true);
2481  }
2482  return ‪$folders;
2483  }
2484 
2492  public function ‪countFoldersInFolder(Folder $folder, $useFilters = true, $recursive = false)
2493  {
2494  $this->‪assureFolderReadPermission($folder);
2495  $filters = $useFilters ? $this->‪getFileAndFolderNameFilters() : [];
2496  return $this->driver->countFoldersInFolder($folder->getIdentifier(), $recursive, $filters);
2497  }
2498 
2505  public function ‪hasFolder($identifier)
2506  {
2508  return $this->driver->folderExists($identifier);
2509  }
2510 
2518  public function ‪hasFolderInFolder($folderName, Folder $folder)
2519  {
2520  $this->‪assureFolderReadPermission($folder);
2521  return $this->driver->folderExistsInFolder($folderName, $folder->getIdentifier());
2522  }
2537  public function ‪createFolder($folderName, ?‪Folder $parentFolder = null)
2538  {
2539  if ($parentFolder === null) {
2540  $parentFolder = $this->‪getRootLevelFolder();
2541  } elseif (!$this->driver->folderExists($parentFolder->getIdentifier())) {
2542  throw new \InvalidArgumentException('Parent folder "' . $parentFolder->getIdentifier() . '" does not exist.', 1325689164);
2543  }
2544  if (!$this->‪checkFolderActionPermission('add', $parentFolder)) {
2545  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to create directories in the folder "' . $parentFolder->getIdentifier() . '"', 1323059807);
2546  }
2547  if ($this->driver->folderExistsInFolder($folderName, $parentFolder->getIdentifier())) {
2548  throw new ‪ExistingTargetFolderException('Folder "' . $folderName . '" already exists.', 1423347324);
2549  }
2550 
2551  $this->eventDispatcher->dispatch(
2552  new ‪BeforeFolderAddedEvent($parentFolder, $folderName)
2553  );
2554 
2555  $newFolder = $this->‪getDriver()->‪createFolder($folderName, $parentFolder->getIdentifier(), true);
2556  $newFolder = $this->‪getFolder($newFolder);
2558  $this->eventDispatcher->dispatch(
2559  new ‪AfterFolderAddedEvent($newFolder)
2560  );
2561 
2562  return $newFolder;
2563  }
2564 
2571  public function ‪getFolderInfo(‪Folder $folder)
2572  {
2573  return $this->driver->getFolderInfoByIdentifier($folder->‪getIdentifier());
2574  }
2575 
2581  public function ‪getDefaultFolder()
2582  {
2583  return $this->‪getFolder($this->driver->getDefaultFolder());
2584  }
2585 
2594  public function ‪getFolder($identifier, $returnInaccessibleFolderObject = false)
2595  {
2596  $data = $this->driver->getFolderInfoByIdentifier($identifier);
2597  $folder = $this->‪createFolderObject($data['identifier'] ?? '', $data['name'] ?? '');
2598 
2599  try {
2600  $this->‪assureFolderReadPermission($folder);
2601  } catch (InsufficientFolderAccessPermissionsException $e) {
2602  $folder = null;
2603  if ($returnInaccessibleFolderObject) {
2604  // if parent folder is readable return inaccessible folder object
2605  $parentPermissions = $this->driver->getPermissions($this->driver->getParentFolderIdentifierOfIdentifier($identifier));
2606  if ($parentPermissions['r']) {
2607  $folder = GeneralUtility::makeInstance(
2608  InaccessibleFolder::class,
2609  ‪$this,
2610  $data['identifier'],
2611  $data['name']
2612  );
2613  }
2614  }
2616  if ($folder === null) {
2617  throw $e;
2618  }
2619  }
2620  return $folder;
2621  }
2622 
2629  public function ‪isWithinProcessingFolder($identifier)
2630  {
2631  $inProcessingFolder = false;
2632  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
2634  $inProcessingFolder = true;
2635  break;
2636  }
2637  }
2638  return $inProcessingFolder;
2639  }
2640 
2649  public function ‪isWithinFolder(Folder $folder, ResourceInterface $resource)
2650  {
2651  if ($folder->getStorage() !== ‪$this) {
2652  throw new \InvalidArgumentException('Given folder "' . $folder->getIdentifier() . '" is not part of this storage!', 1422709241);
2653  }
2654  if ($folder->getStorage() !== $resource->getStorage()) {
2655  return false;
2656  }
2657  return $this->driver->isWithin($folder->getIdentifier(), $resource->getIdentifier());
2658  }
2659 
2668  public function ‪getRootLevelFolder($respectFileMounts = true)
2669  {
2670  if ($respectFileMounts && !empty($this->fileMounts)) {
2671  $mount = reset($this->fileMounts);
2672  return $mount['folder'];
2673  }
2674  return $this->‪createFolderObject($this->driver->getRootLevelFolder(), '');
2675  }
2676 
2692  protected function ‪getUniqueName(FolderInterface $folder, $theFile, $dontCheckForUnique = false)
2693  {
2694  $maxNumber = 99;
2695  // Fetches info about path, name, extension of $theFile
2696  $origFileInfo = ‪PathUtility::pathinfo($theFile);
2697  // Check if the file exists and if not - return the fileName...
2698  // The destinations file
2699  $theDestFile = $origFileInfo['basename'];
2700  // If the file does NOT exist we return this fileName
2701  if ($dontCheckForUnique || (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier()) && !‪$this->driver->folderExistsInFolder($theDestFile, $folder->getIdentifier()))) {
2702  return $theDestFile;
2703  }
2704  // Well the fileName in its pure form existed. Now we try to append
2705  // numbers / unique-strings and see if we can find an available fileName
2706  // This removes _xx if appended to the file
2707  $theTempFileBody = preg_replace('/_[0-9][0-9]$/', '', $origFileInfo['filename']);
2708  $theOrigExt = ($origFileInfo['extension'] ?? '') ? '.' . $origFileInfo['extension'] : '';
2709  for ($a = 1; $a <= $maxNumber + 1; $a++) {
2710  // First we try to append numbers
2711  if ($a <= $maxNumber) {
2712  $insert = '_' . sprintf('%02d', $a);
2713  } else {
2714  $insert = '_' . substr(md5(‪StringUtility::getUniqueId()), 0, 6);
2715  }
2716  $theTestFile = $theTempFileBody . $insert . $theOrigExt;
2717  // The destinations file
2718  $theDestFile = $theTestFile;
2719  // If the file does NOT exist we return this fileName
2720  if (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier()) && !‪$this->driver->folderExistsInFolder($theDestFile, $folder->getIdentifier())) {
2721  return $theDestFile;
2722  }
2723  }
2724  throw new \RuntimeException('Last possible name "' . $theDestFile . '" is already taken.', 1325194291);
2725  }
2726 
2730  protected function ‪getFileFactory()
2731  {
2732  return GeneralUtility::makeInstance(ResourceFactory::class);
2733  }
2734 
2738  protected function ‪getFileIndexRepository()
2739  {
2740  return GeneralUtility::makeInstance(FileIndexRepository::class);
2741  }
2742 
2746  protected function ‪getFileProcessingService()
2747  {
2748  if (!$this->fileProcessingService) {
2749  $this->fileProcessingService = GeneralUtility::makeInstance(FileProcessingService::class, ‪$this, $this->driver, $this->eventDispatcher);
2750  }
2752  }
2753 
2760  public function ‪getRole(‪FolderInterface $folder)
2761  {
2762  $folderRole = ‪FolderInterface::ROLE_DEFAULT;
2763  $identifier = $folder->‪getIdentifier();
2764  if (method_exists($this->driver, 'getRole')) {
2765  $folderRole = $this->driver->getRole($folder->‪getIdentifier());
2766  }
2767  if (isset($this->fileMounts[$identifier])) {
2768  $folderRole = ‪FolderInterface::ROLE_MOUNT;
2769 
2770  if (!empty($this->fileMounts[$identifier]['read_only'])) {
2772  }
2773  if ($this->fileMounts[$identifier]['user_mount'] ?? false) {
2775  }
2776  }
2777  if ($folder instanceof ‪Folder && $this->‪isProcessingFolder($folder)) {
2779  }
2780 
2781  return $folderRole;
2782  }
2783 
2791  public function ‪getProcessingFolder(?File $file = null)
2792  {
2793  // If a file is given, make sure to return the processing folder of the correct storage
2794  if ($file !== null && $file->getStorage()->getUid() !== ‪$this->getUid()) {
2795  return $file->‪getStorage()->‪getProcessingFolder($file);
2796  }
2797  if (!isset($this->processingFolder)) {
2799  if (!empty($this->storageRecord['processingfolder'])) {
2800  ‪$processingFolder = $this->storageRecord['processingfolder'];
2801  }
2802  try {
2803  if (str_contains(‪$processingFolder, ':')) {
2804  [$storageUid, $processingFolderIdentifier] = explode(':', ‪$processingFolder, 2);
2805  $storage = GeneralUtility::makeInstance(StorageRepository::class)->findByUid((int)$storageUid);
2806  if ($storage->hasFolder($processingFolderIdentifier)) {
2807  $this->processingFolder = $storage->getFolder($processingFolderIdentifier);
2808  } else {
2809  $rootFolder = $storage->getRootLevelFolder(false);
2810  $currentEvaluatePermissions = $storage->getEvaluatePermissions();
2811  $storage->setEvaluatePermissions(false);
2812  $this->processingFolder = $storage->createFolder(
2813  ltrim($processingFolderIdentifier, '/'),
2814  $rootFolder
2815  );
2816  $storage->setEvaluatePermissions($currentEvaluatePermissions);
2817  }
2818  } else {
2819  if ($this->driver->folderExists(‪$processingFolder) === false) {
2820  $rootFolder = $this->‪getRootLevelFolder(false);
2821  try {
2822  $currentEvaluatePermissions = ‪$this->evaluatePermissions;
2823  $this->evaluatePermissions = false;
2824  $this->processingFolder = $this->‪createFolder(
2825  $processingFolder,
2826  $rootFolder
2827  );
2828  $this->evaluatePermissions = $currentEvaluatePermissions;
2829  } catch (\InvalidArgumentException $e) {
2830  $this->processingFolder = GeneralUtility::makeInstance(
2831  InaccessibleFolder::class,
2832  ‪$this,
2835  );
2836  }
2837  } else {
2838  $data = $this->driver->getFolderInfoByIdentifier(‪$processingFolder);
2839  $this->processingFolder = $this->‪createFolderObject($data['identifier'], $data['name']);
2840  }
2841  }
2842  } catch (InsufficientFolderWritePermissionsException|ResourcePermissionsUnavailableException $e) {
2843  $this->processingFolder = GeneralUtility::makeInstance(
2844  InaccessibleFolder::class,
2845  ‪$this,
2848  );
2849  }
2850  }
2851 
2853  if (!empty($file)) {
2855  }
2856  return ‪$processingFolder;
2857  }
2858 
2868  protected function ‪getNestedProcessingFolder(File $file, Folder $rootProcessingFolder)
2869  {
2870  ‪$processingFolder = $rootProcessingFolder;
2871  $nestedFolderNames = $this->‪getNamesForNestedProcessingFolder(
2872  $file->getIdentifier(),
2873  self::PROCESSING_FOLDER_LEVELS
2874  );
2875 
2876  try {
2877  foreach ($nestedFolderNames as $folderName) {
2878  if (‪$processingFolder->‪hasFolder($folderName)) {
2880  } else {
2881  $currentEvaluatePermissions = ‪$processingFolder->‪getStorage()->‪getEvaluatePermissions();
2884  ‪$processingFolder->‪getStorage()->‪setEvaluatePermissions($currentEvaluatePermissions);
2885  }
2886  }
2887  } catch (FolderDoesNotExistException $e) {
2888  }
2889 
2890  return ‪$processingFolder;
2891  }
2892 
2900  protected function ‪getNamesForNestedProcessingFolder($fileIdentifier, $levels)
2901  {
2902  $names = [];
2903  if ($levels === 0) {
2904  return $names;
2905  }
2906  $hash = md5($fileIdentifier);
2907  for ($i = 1; $i <= $levels; $i++) {
2908  $names[] = substr($hash, $i, 1);
2909  }
2910  return $names;
2911  }
2912 
2918  public function ‪getDriverType()
2919  {
2920  return $this->storageRecord['driver'];
2921  }
2928  protected function ‪getIndexer()
2929  {
2930  return GeneralUtility::makeInstance(Indexer::class, ‪$this);
2931  }
2932 
2936  public function ‪setDefault(‪$isDefault)
2937  {
2938  $this->‪isDefault = (bool)‪$isDefault;
2939  }
2940 
2944  public function ‪isDefault()
2945  {
2946  return ‪$this->isDefault;
2947  }
2953  {
2954  return GeneralUtility::makeInstance(ResourceFactory::class);
2955  }
2956 
2962  protected function ‪getBackendUser()
2963  {
2964  return ‪$GLOBALS['BE_USER'];
2965  }
2966 
2978  protected function ‪getNearestRecyclerFolder(‪FileInterface $file)
2979  {
2980  if ($file instanceof ‪ProcessedFile) {
2981  return null;
2982  }
2983  // if the storage is not browsable we cannot fetch the parent folder of the file so no recycler handling is possible
2984  if (!$this->‪isBrowsable()) {
2985  return null;
2986  }
2987 
2988  $recyclerFolder = null;
2989  $folder = $file->‪getParentFolder();
2990 
2991  do {
2992  if ($folder->getRole() === ‪FolderInterface::ROLE_RECYCLER) {
2993  break;
2994  }
2995 
2996  foreach ($folder->getSubfolders() as $subFolder) {
2997  if ($subFolder->getRole() === ‪FolderInterface::ROLE_RECYCLER) {
2998  $recyclerFolder = $subFolder;
2999  break;
3000  }
3001  }
3002 
3003  $parentFolder = $folder->‪getParentFolder();
3004  $isFolderLoop = $folder->‪getIdentifier() === $parentFolder->getIdentifier();
3005  $folder = $parentFolder;
3006  } while ($recyclerFolder === null && !$isFolderLoop);
3007 
3008  return $recyclerFolder;
3009  }
3010 
3018  protected function ‪createFolderObject(string $identifier, string $name)
3019  {
3020  return GeneralUtility::makeInstance(Folder::class, ‪$this, $identifier, $name);
3021  }
3022 }
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderRenamedEvent
Definition: BeforeFolderRenamedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileProcessingService
‪Service FileProcessingService getFileProcessingService()
Definition: ResourceStorage.php:2732
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileAndFolderNameFilters
‪array $fileAndFolderNameFilters
Definition: ResourceStorage.php:205
‪TYPO3\CMS\Core\Http\ApplicationType\fromRequest
‪static static fromRequest(ServerRequestInterface $request)
Definition: ApplicationType.php:62
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:999
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileByIdentifier
‪File ProcessedFile null getFileByIdentifier(string $fileIdentifier)
Definition: ResourceStorage.php:1482
‪TYPO3\CMS\Core\Resource\Search\Result\EmptyFileSearchResult
Definition: EmptyFileSearchResult.php:24
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderDeletedEvent
Definition: BeforeFolderDeletedEvent.php:28
‪TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile
‪File getOriginalFile()
Definition: ProcessedFile.php:305
‪TYPO3\CMS\Core\Resource\ProcessedFileRepository
Definition: ProcessedFileRepository.php:31
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileWritePermissionsException
Definition: InsufficientFileWritePermissionsException.php:21
‪TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException
Definition: InsufficientUserPermissionsException.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasHierarchicalIdentifiers
‪bool hasHierarchicalIdentifiers()
Definition: ResourceStorage.php:423
‪TYPO3\CMS\Core\Resource\ResourceStorage\renameFolder
‪Folder renameFolder($folderObject, $newName)
Definition: ResourceStorage.php:2352
‪TYPO3\CMS\Core\Resource\Event\BeforeFileCopiedEvent
Definition: BeforeFileCopiedEvent.php:30
‪TYPO3\CMS\Core\Resource\FileInterface\getExtension
‪string getExtension()
‪TYPO3\CMS\Core\Resource\ResourceStorage\deleteFolder
‪bool deleteFolder($folderObject, $deleteRecursively=false)
Definition: ResourceStorage.php:2395
‪TYPO3\CMS\Core\Resource\ResourceStorage\sanitizeFileName
‪string sanitizeFileName($fileName, ?Folder $targetFolder=null)
Definition: ResourceStorage.php:1225
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository
Definition: FileIndexRepository.php:42
‪TYPO3\CMS\Core\Resource\Event\BeforeFileCreatedEvent
Definition: BeforeFileCreatedEvent.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileAndFolderNameFilter
‪addFileAndFolderNameFilter($filter)
Definition: ResourceStorage.php:1576
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:25
‪TYPO3\CMS\Core\Resource\ResourceStorage\resetFileAndFolderNameFiltersToDefault
‪resetFileAndFolderNameFiltersToDefault()
Definition: ResourceStorage.php:1535
‪TYPO3\CMS\Core\Resource\ResourceStorage\countFilesInFolder
‪int countFilesInFolder(Folder $folder, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1666
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry
Definition: OnlineMediaHelperRegistry.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInfo
‪array getFileInfo(FileInterface $fileObject)
Definition: ResourceStorage.php:1506
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface
Definition: ResourceStorageInterface.php:22
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException
Definition: ExistingTargetFolderException.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\markAsTemporaryOffline
‪markAsTemporaryOffline()
Definition: ResourceStorage.php:538
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUid
‪int getUid()
Definition: ResourceStorage.php:330
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:206
‪TYPO3\CMS\Core\Resource\AbstractFile\getPublicUrl
‪string null getPublicUrl($relativeToCurrentScript=false)
Definition: AbstractFile.php:564
‪TYPO3\CMS\Core\Resource\ResourceStorage\setUserPermissions
‪setUserPermissions(array $userPermissions)
Definition: ResourceStorage.php:675
‪TYPO3\CMS\Core\Resource\AbstractFile\getIdentifier
‪string getIdentifier()
Definition: AbstractFile.php:141
‪TYPO3\CMS\Core\Resource\Event\BeforeFileReplacedEvent
Definition: BeforeFileReplacedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInfoByIdentifier
‪array getFileInfoByIdentifier($identifier, array $propertiesToExtract=[])
Definition: ResourceStorage.php:1519
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface\createFolder
‪string createFolder($newFolderName, $parentFolderIdentifier='', $recursive=false)
‪TYPO3\CMS\Core\Resource\ResourceStorage\getEvaluatePermissions
‪bool getEvaluatePermissions()
Definition: ResourceStorage.php:665
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderInFolder
‪Folder InaccessibleFolder getFolderInFolder($folderName, Folder $parentFolder, $returnInaccessibleFolderObject=false)
Definition: ResourceStorage.php:2429
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\CANCEL
‪const CANCEL
Definition: DuplicationBehavior.php:46
‪TYPO3\CMS\Core\Resource\ResourceStorage\getPublicUrl
‪string null getPublicUrl(ResourceInterface $resourceObject, $relativeToCurrentScript=false)
Definition: ResourceStorage.php:1374
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileReplacePermissions
‪assureFileReplacePermissions(FileInterface $file)
Definition: ResourceStorage.php:951
‪TYPO3\CMS\Core\Resource\ResourceStorage\PROCESSING_FOLDER_LEVELS
‪const PROCESSING_FOLDER_LEVELS
Definition: ResourceStorage.php:210
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileReadPermissionsException
Definition: InsufficientFileReadPermissionsException.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDefaultFolder
‪Folder getDefaultFolder()
Definition: ResourceStorage.php:2567
‪TYPO3\CMS\Core\Resource\FileInterface
Definition: FileInterface.php:22
‪TYPO3\CMS\Core\Resource\AbstractFile\getForLocalProcessing
‪string getForLocalProcessing($writable=true)
Definition: AbstractFile.php:583
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
Definition: InsufficientFolderAccessPermissionsException.php:23
‪TYPO3\CMS\Core\Resource\AbstractFile\getName
‪string getName()
Definition: AbstractFile.php:161
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFolder
‪Folder moveFolder(Folder $folderToMove, Folder $targetParentFolder, $newFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2224
‪TYPO3\CMS\Core\Resource\Folder\getParentFolder
‪FolderInterface getParentFolder()
Definition: Folder.php:550
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDriverType
‪string getDriverType()
Definition: ResourceStorage.php:2904
‪TYPO3\CMS\Core\Utility\PathUtility\dirname
‪static string dirname($path)
Definition: PathUtility.php:251
‪TYPO3\CMS\Core\Resource\Security\FileNameValidator
Definition: FileNameValidator.php:25
‪TYPO3\CMS\Core\Resource\ResourceStorage\processFile
‪ProcessedFile processFile(FileInterface $fileObject, $context, array $configuration)
Definition: ResourceStorage.php:1436
‪TYPO3\CMS\Core\Resource\ResourceStorage\$storageRecord
‪array $storageRecord
Definition: ResourceStorage.php:136
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_DEFAULT
‪const ROLE_DEFAULT
Definition: FolderInterface.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileExtensionPermission
‪bool checkFileExtensionPermission($fileName)
Definition: ResourceStorage.php:833
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFilesInFolder
‪File[] getFilesInFolder(Folder $folder, $start=0, $maxNumberOfItems=0, $useFilters=true, $recursive=false, $sort='', $sortRev=false)
Definition: ResourceStorage.php:1619
‪TYPO3\CMS\Core\Resource\ResourceStorage\getStorageRecord
‪array getStorageRecord()
Definition: ResourceStorage.php:288
‪TYPO3
‪TYPO3\CMS\Core\Resource\Index\Indexer\updateIndexEntry
‪File updateIndexEntry(File $fileObject)
Definition: Indexer.php:99
‪TYPO3\CMS\Core\Resource\Event\AfterFolderMovedEvent
Definition: AfterFolderMovedEvent.php:29
‪TYPO3\CMS\Core\Resource\Event\BeforeFileDeletedEvent
Definition: BeforeFileDeletedEvent.php:28
‪TYPO3\CMS\Core\Resource\Index\Indexer
Definition: Indexer.php:34
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileFactory
‪ResourceFactory getFileFactory()
Definition: ResourceStorage.php:2716
‪TYPO3\CMS\Core\Resource\Index\Indexer\createIndexEntry
‪File createIndexEntry($identifier)
Definition: Indexer.php:68
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileMount
‪addFileMount($folderIdentifier, $additionalData=[])
Definition: ResourceStorage.php:558
‪TYPO3\CMS\Core\Registry
Definition: Registry.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\$configuration
‪array $configuration
Definition: ResourceStorage.php:142
‪TYPO3\CMS\Core\Resource\ResourceStorage\copyFolderBetweenStorages
‪copyFolderBetweenStorages(FolderInterface $folderToCopy, FolderInterface $targetParentFolder, $newFolderName)
Definition: ResourceStorage.php:2338
‪TYPO3\CMS\Core\Resource\Event\AfterFolderCopiedEvent
Definition: AfterFolderCopiedEvent.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolder
‪Folder InaccessibleFolder getFolder($identifier, $returnInaccessibleFolderObject=false)
Definition: ResourceStorage.php:2580
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderIdentifierFromFileIdentifier
‪string getFolderIdentifierFromFileIdentifier($fileIdentifier)
Definition: ResourceStorage.php:1586
‪TYPO3\CMS\Core\Resource\ResourceStorage\replaceFile
‪FileInterface replaceFile(FileInterface $file, $localFilePath)
Definition: ResourceStorage.php:2133
‪TYPO3\CMS\Core\Resource\ResourceStorage\renameFile
‪FileInterface renameFile($file, $targetFileName, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2080
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface
Definition: DriverInterface.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFile
‪FileInterface getFile($identifier)
Definition: ResourceStorage.php:1465
‪TYPO3\CMS\Core\Resource\Event\BeforeFileRenamedEvent
Definition: BeforeFileRenamedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDriver
‪Driver DriverInterface getDriver()
Definition: ResourceStorage.php:310
‪TYPO3\CMS\Core\Resource\ResourceStorage\$isOnline
‪bool $isOnline
Definition: ResourceStorage.php:195
‪TYPO3\CMS\Core\Resource\Event\AfterFileCreatedEvent
Definition: AfterFileCreatedEvent.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFileByIdentifier
‪string hashFileByIdentifier($fileIdentifier, $hash)
Definition: ResourceStorage.php:1338
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\withFolder
‪withFolder(Folder $folder)
Definition: FileSearchDemand.php:118
‪TYPO3\CMS\Core\Resource\ResourceStorage\fileAndFolderNameFilters
‪array< int, function getImportExportFilter():array { $filter=GeneralUtility::makeInstance(ImportExportFilter::class);return[ $filter, 'filterImportExportFilesAndFolders'];} public array function getFileAndFolderNameFilters() { return array_merge( $this->fileAndFolderNameFilters,[ $this->getImportExportFilter()]);} public $this function setFileAndFolderNameFilters(array $filters) { $this-> fileAndFolderNameFilters
Definition: ResourceStorage.php:1569
‪TYPO3\CMS\Core\Resource\FileInterface\getSize
‪int getSize()
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
Definition: ExistingTargetFileNameException.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\DEFAULT_ProcessingFolder
‪const DEFAULT_ProcessingFolder
Definition: ResourceStorageInterface.php:43
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasCapability
‪bool hasCapability($capability)
Definition: ResourceStorage.php:379
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessingFolders
‪Folder[] getProcessingFolders()
Definition: ResourceStorage.php:1705
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileIdentifiersInFolder
‪array getFileIdentifiersInFolder($folderIdentifier, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1653
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository\findByFolder
‪array null findByFolder(Folder $folder)
Definition: FileIndexRepository.php:189
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderInfo
‪array getFolderInfo(Folder $folder)
Definition: ResourceStorage.php:2557
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessedFileRepository
‪getProcessedFileRepository()
Definition: ResourceStorage.php:1494
‪TYPO3\CMS\Core\Resource\Event\BeforeFileMovedEvent
Definition: BeforeFileMovedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceInterface\getIdentifier
‪string getIdentifier()
‪TYPO3\CMS\Core\Resource\ResourceInterface\getStorage
‪ResourceStorage getStorage()
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFolder
‪bool hasFolder($identifier)
Definition: ResourceStorage.php:2491
‪TYPO3\CMS\Core\Resource\Event\AfterFolderAddedEvent
Definition: AfterFolderAddedEvent.php:28
‪TYPO3\CMS\Core\Resource\Exception\ResourcePermissionsUnavailableException
Definition: ResourcePermissionsUnavailableException.php:25
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinFileMountBoundaries
‪bool isWithinFileMountBoundaries($subject, $checkWriteAccess=false)
Definition: ResourceStorage.php:611
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileContents
‪string getFileContents($file)
Definition: ResourceStorage.php:1769
‪TYPO3\CMS\Core\Utility\PathUtility\getCanonicalPath
‪static string getCanonicalPath($path)
Definition: PathUtility.php:380
‪TYPO3\CMS\Core\Resource\ResourceStorage\isDefault
‪bool isDefault()
Definition: ResourceStorage.php:2930
‪TYPO3\CMS\Core\Http\ApplicationType
Definition: ApplicationType.php:52
‪TYPO3\CMS\Core\Resource\ResourceStorage\isProcessingFolder
‪bool isProcessingFolder(Folder $folder)
Definition: ResourceStorage.php:1736
‪TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException
Definition: IllegalFileExtensionException.php:23
‪TYPO3\CMS\Core\Resource\Event\AfterFileMovedEvent
Definition: AfterFileMovedEvent.php:31
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInFolder
‪File ProcessedFile null getFileInFolder($fileName, Folder $folder)
Definition: ResourceStorage.php:1598
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFile
‪bool hasFile($identifier)
Definition: ResourceStorage.php:1691
‪TYPO3\CMS\Core\Utility\PathUtility\basename
‪static string basename($path)
Definition: PathUtility.php:226
‪TYPO3\CMS\Core\Resource\ResourceStorage\setFileContents
‪int setFileContents(AbstractFile $file, $contents)
Definition: ResourceStorage.php:1847
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException
Definition: InsufficientFileAccessPermissionsException.php:23
‪TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException
Definition: InvalidTargetFolderException.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\getRootLevelFolder
‪Folder getRootLevelFolder($respectFileMounts=true)
Definition: ResourceStorage.php:2654
‪TYPO3\CMS\Core\Resource\Event\AfterFolderRenamedEvent
Definition: AfterFolderRenamedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\$folderIdentifiers
‪$folderIdentifiers
Definition: ResourceStorage.php:2453
‪TYPO3\CMS\Core\Resource\Folder\getName
‪string getName()
Definition: Folder.php:94
‪TYPO3\CMS\Core\Resource\Exception\UploadException
Definition: UploadException.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFolder
‪Folder createFolder($folderName, ?Folder $parentFolder=null)
Definition: ResourceStorage.php:2523
‪TYPO3\CMS\Core\Resource\ResourceStorage\$capabilities
‪int $capabilities
Definition: ResourceStorage.php:175
‪TYPO3\CMS\Core\Service\FlexFormService
Definition: FlexFormService.php:25
‪TYPO3\CMS\Core\Resource\Event\GeneratePublicUrlForResourceEvent
Definition: GeneratePublicUrlForResourceEvent.php:31
‪TYPO3\CMS\Core\Utility\PathUtility\getRelativePathTo
‪static string null getRelativePathTo($targetPath)
Definition: PathUtility.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\$processingFolder
‪Folder null $processingFolder
Definition: ResourceStorage.php:183
‪TYPO3\CMS\Core\Resource\Folder\getStorage
‪ResourceStorage getStorage()
Definition: Folder.php:149
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFileIdentifier
‪string hashFileIdentifier($file)
Definition: ResourceStorage.php:1355
‪TYPO3\CMS\Core\Resource\ResourceStorage\searchFiles
‪FileSearchResultInterface searchFiles(FileSearchDemand $searchDemand, ?Folder $folder=null, bool $useFilters=true)
Definition: ResourceStorage.php:437
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFile
‪FileInterface addFile($localFilePath, Folder $targetFolder, $targetFileName='', $conflictMode=DuplicationBehavior::RENAME, $removeOriginal=true)
Definition: ResourceStorage.php:1254
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileAndFolderNameFilters
‪array< string|int, getFoldersInFolder(Folder $folder, $start=0, $maxNumberOfItems=0, $useFilters=true, $recursive=false, $sort='', $sortRev=false) { $filters=$useFilters==true ? $this-> getFileAndFolderNameFilters()
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileReadPermission
‪assureFileReadPermission(FileInterface $file)
Definition: ResourceStorage.php:909
‪TYPO3\CMS\Core\Resource\ResourceStorage\$driver
‪Driver DriverInterface $driver
Definition: ResourceStorage.php:130
‪TYPO3\CMS\Core\Resource\ResourceStorage\isOnline
‪bool isOnline()
Definition: ResourceStorage.php:468
‪TYPO3\CMS\Core\Resource\InaccessibleFolder
Definition: InaccessibleFolder.php:29
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\setEvaluatePermissions
‪setEvaluatePermissions($evaluatePermissions)
Definition: ResourceStorage.php:654
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFile
‪FileInterface moveFile($file, $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2013
‪TYPO3\CMS\Core\Resource\AbstractFile
Definition: AbstractFile.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\getRole
‪string getRole(FolderInterface $folder)
Definition: ResourceStorage.php:2746
‪TYPO3\CMS\Core\Resource\ResourceStorage\markAsPermanentlyOffline
‪markAsPermanentlyOffline()
Definition: ResourceStorage.php:516
‪TYPO3\CMS\Core\Resource\Exception\InvalidConfigurationException
Definition: InvalidConfigurationException.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\getAllFileObjectsInFolder
‪File[] getAllFileObjectsInFolder(Folder $folder)
Definition: ResourceStorage.php:2192
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileMovePermissions
‪assureFileMovePermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
Definition: ResourceStorage.php:1060
‪TYPO3\CMS\Core\Resource\Search\Result\FileSearchResult
Definition: FileSearchResult.php:31
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderAddedEvent
Definition: BeforeFolderAddedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileAddPermissions
‪assureFileAddPermissions($targetFolder, $targetFileName)
Definition: ResourceStorage.php:1003
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessingFolder
‪Folder getProcessingFolder(?File $file=null)
Definition: ResourceStorage.php:2777
‪TYPO3\CMS\Core\Resource\ResourceStorage\getCapabilities
‪int getCapabilities()
Definition: ResourceStorage.php:368
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface\isWithin
‪bool isWithin($folderIdentifier, $identifier)
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileForLocalProcessing
‪string getFileForLocalProcessing(FileInterface $fileObject, $writable=true)
Definition: ResourceStorage.php:1453
‪TYPO3\CMS\Core\Resource\ResourceStorage\isBrowsable
‪bool isBrowsable()
Definition: ResourceStorage.php:413
‪TYPO3\CMS\Core\Resource\Folder\createFolder
‪Folder createFolder($folderName)
Definition: Folder.php:363
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand
Definition: FileSearchDemand.php:26
‪TYPO3\CMS\Core\Resource\Search\Result\DriverFilteredSearchResult
Definition: DriverFilteredSearchResult.php:29
‪TYPO3\CMS\Core\Resource\Exception\UploadSizeException
Definition: UploadSizeException.php:21
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:37
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:41
‪TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException
Definition: FolderDoesNotExistException.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFile
‪FileInterface createFile($fileName, Folder $targetFolderObject)
Definition: ResourceStorage.php:1877
‪TYPO3\CMS\Core\Resource\Event\AfterFileRenamedEvent
Definition: AfterFileRenamedEvent.php:27
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinFolder
‪bool isWithinFolder(Folder $folder, ResourceInterface $resource)
Definition: ResourceStorage.php:2635
‪TYPO3\CMS\Core\Resource\Event\AfterFileContentsSetEvent
Definition: AfterFileContentsSetEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\__construct
‪__construct(DriverInterface $driver, array $storageRecord, ?EventDispatcherInterface $eventDispatcher=null)
Definition: ResourceStorage.php:219
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\RENAME
‪const RENAME
Definition: DuplicationBehavior.php:32
‪TYPO3\CMS\Core\Resource\Folder\checkActionPermission
‪bool checkActionPermission($action)
Definition: Folder.php:436
‪TYPO3\CMS\Core\Resource\ResourceStorage\autoExtractMetadataEnabled
‪bool autoExtractMetadataEnabled()
Definition: ResourceStorage.php:504
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileDeletePermissions
‪assureFileDeletePermissions(FileInterface $file)
Definition: ResourceStorage.php:971
‪TYPO3\CMS\Core\Resource\ResourceStorage\getConfiguration
‪array getConfiguration()
Definition: ResourceStorage.php:268
‪TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: AbstractFile.php:452
‪TYPO3\CMS\Core\Resource\Event\AfterFileCopiedEvent
Definition: AfterFileCopiedEvent.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasChildren
‪bool hasChildren()
Definition: ResourceStorage.php:340
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileMounts
‪array getFileMounts()
Definition: ResourceStorage.php:598
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_PROCESSING
‪const ROLE_PROCESSING
Definition: FolderInterface.php:28
‪TYPO3\CMS\Core\Resource\Folder\getRole
‪string getRole()
Definition: Folder.php:535
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinProcessingFolder
‪bool isWithinProcessingFolder($identifier)
Definition: ResourceStorage.php:2615
‪TYPO3\CMS\Core\Utility\PathUtility\pathinfo
‪static string string[] pathinfo($path, $options=null)
Definition: PathUtility.php:277
‪TYPO3\CMS\Core\Resource\ResourceStorage\getBackendUser
‪TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser()
Definition: ResourceStorage.php:2948
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFolderBetweenStorages
‪moveFolderBetweenStorages(Folder $folderToMove, Folder $targetParentFolder, $newFolderName)
Definition: ResourceStorage.php:2273
‪TYPO3\CMS\Core\Resource\ResourceStorage\$eventDispatcher
‪EventDispatcherInterface $eventDispatcher
Definition: ResourceStorage.php:179
‪TYPO3\CMS\Core\Resource\Folder\getFiles
‪TYPO3 CMS Core Resource File[] getFiles($start=0, $numberOfItems=0, $filterMode=self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, $recursive=false, $sort='', $sortRev=false)
Definition: Folder.php:219
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderCopyPermissions
‪assureFolderCopyPermissions(FolderInterface $folderToCopy, FolderInterface $targetParentFolder)
Definition: ResourceStorage.php:1157
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFileObjectFromCombinedIdentifier
‪File ProcessedFile null getFileObjectFromCombinedIdentifier($identifier)
Definition: ResourceFactory.php:234
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_MOUNT
‪const ROLE_MOUNT
Definition: FolderInterface.php:31
‪TYPO3\CMS\Core\Resource\AbstractFile\getParentFolder
‪FolderInterface getParentFolder()
Definition: AbstractFile.php:608
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileProcessingService
‪Service FileProcessingService $fileProcessingService
Definition: ResourceStorage.php:146
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNamesForNestedProcessingFolder
‪string[] getNamesForNestedProcessingFolder($fileIdentifier, $levels)
Definition: ResourceStorage.php:2886
‪TYPO3\CMS\Core\Resource\ResourceStorage\$folders
‪foreach($folderIdentifiers as $folderIdentifier) return $folders
Definition: ResourceStorage.php:2464
‪TYPO3\CMS\Core\Resource\ResourceStorage\streamFile
‪ResponseInterface streamFile(FileInterface $file, bool $asDownload=false, ?string $alternativeFilename=null, ?string $overrideMimeType=null)
Definition: ResourceStorage.php:1784
‪TYPO3\CMS\Core\Resource\Search\Result\FileSearchResultInterface
Definition: FileSearchResultInterface.php:24
‪TYPO3\CMS\Core\Resource\Folder\getSubfolder
‪Folder getSubfolder($name)
Definition: Folder.php:274
‪TYPO3\CMS\Core\Resource\ResourceInterface\getName
‪string getName()
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFolderObject
‪Folder createFolderObject(string $identifier, string $name)
Definition: ResourceStorage.php:3004
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_USER_MOUNT
‪const ROLE_USER_MOUNT
Definition: FolderInterface.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFolderActionPermission
‪bool checkFolderActionPermission($action, ?Folder $folder=null)
Definition: ResourceStorage.php:782
‪TYPO3\CMS\Core\Resource\ResourceStorage\$isDefault
‪bool $isDefault
Definition: ResourceStorage.php:199
‪TYPO3\CMS\Core\Resource
Definition: generateMimeTypes.php:54
‪TYPO3\CMS\Core\Resource\ProcessedFile
Definition: ProcessedFile.php:45
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_BROWSABLE
‪const CAPABILITY_BROWSABLE
Definition: ResourceStorageInterface.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\$this
‪return $this
Definition: ResourceStorage.php:1570
‪TYPO3\CMS\Core\Resource\ResourceStorage\$processingFolders
‪Folder[] $processingFolders
Definition: ResourceStorage.php:189
‪TYPO3\CMS\Core\Resource\Event\BeforeFileAddedEvent
Definition: BeforeFileAddedEvent.php:30
‪TYPO3\CMS\Core\Utility\GeneralUtility\isValidUrl
‪static bool isValidUrl($url)
Definition: GeneralUtility.php:883
‪TYPO3\CMS\Core\Resource\ResourceStorage\usesCaseSensitiveIdentifiers
‪bool usesCaseSensitiveIdentifiers()
Definition: ResourceStorage.php:458
‪TYPO3\CMS\Core\Resource\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Core\Http\FalDumpFileContentsDecoratorStream
Definition: FalDumpFileContentsDecoratorStream.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFileInFolder
‪bool hasFileInFolder($fileName, Folder $folder)
Definition: ResourceStorage.php:1755
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_READONLY_MOUNT
‪const ROLE_READONLY_MOUNT
Definition: FolderInterface.php:32
‪TYPO3\CMS\Core\Resource\AbstractFile\setIdentifier
‪File setIdentifier($identifier)
Definition: AbstractFile.php:440
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileCopyPermissions
‪assureFileCopyPermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
Definition: ResourceStorage.php:1123
‪TYPO3\CMS\Core\Resource\ResourceStorage\getPseudoStream
‪ResponseInterface getPseudoStream(FileInterface $file, bool $asDownload=false, ?string $alternativeFilename=null, ?string $overrideMimeType=null)
Definition: ResourceStorage.php:1812
‪TYPO3\CMS\Core\Resource\ResourceStorage\$evaluatePermissions
‪bool $evaluatePermissions
Definition: ResourceStorage.php:155
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:125
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:128
‪TYPO3\CMS\Core\Resource\ResourceStorage\setDriver
‪ResourceStorage setDriver(DriverInterface $driver)
Definition: ResourceStorage.php:299
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderCopiedEvent
Definition: BeforeFolderCopiedEvent.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderMovePermissions
‪assureFolderMovePermissions(FolderInterface $folderToMove, FolderInterface $targetParentFolder)
Definition: ResourceStorage.php:1193
‪TYPO3\CMS\Core\Resource\ResourceStorage\isPublic
‪bool isPublic()
Definition: ResourceStorage.php:392
‪TYPO3\CMS\Core\Log\LogManager
Definition: LogManager.php:33
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:43
‪if
‪if(PHP_SAPI !=='cli')
Definition: checkNamespaceIntegrity.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNearestRecyclerFolder
‪Folder null getNearestRecyclerFolder(FileInterface $file)
Definition: ResourceStorage.php:2964
‪TYPO3\CMS\Core\Resource\ResourceStorage\countFoldersInFolder
‪int countFoldersInFolder(Folder $folder, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:2478
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_RECYCLER
‪const ROLE_RECYCLER
Definition: FolderInterface.php:27
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException
Definition: InsufficientFolderWritePermissionsException.php:21
‪TYPO3\CMS\Core\Resource\FolderInterface
Definition: FolderInterface.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFile
‪string hashFile(FileInterface $fileObject, $hash)
Definition: ResourceStorage.php:1325
‪TYPO3\CMS\Core\Resource\ResourceStorage\addUploadedFile
‪FileInterface addUploadedFile(array $uploadedFileData, ?Folder $targetFolder=null, $targetFileName=null, $conflictMode=DuplicationBehavior::CANCEL)
Definition: ResourceStorage.php:2161
‪TYPO3\CMS\Core\Resource\ResourceStorage\setConfiguration
‪setConfiguration(array $configuration)
Definition: ResourceStorage.php:278
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFileObject
‪File getFileObject($uid, array $fileData=[])
Definition: ResourceFactory.php:209
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkValidFileExtension
‪checkValidFileExtension(FileInterface $file)
Definition: ResourceStorage.php:843
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileRenamePermissions
‪assureFileRenamePermissions(FileInterface $file, $targetFileName)
Definition: ResourceStorage.php:1090
‪TYPO3\CMS\Core\Utility\Exception\NotImplementedMethodException
Definition: NotImplementedMethodException.php:26
‪TYPO3\CMS\Core\Resource\Filter\ImportExportFilter
Definition: ImportExportFilter.php:31
‪TYPO3\CMS\Core\Resource\Folder\getIdentifier
‪string getIdentifier()
Definition: Folder.php:160
‪TYPO3\CMS\Core\Resource\ResourceStorage\$folders
‪foreach($this->getProcessingFolders() as $processingFolder) $folders
Definition: ResourceStorage.php:2463
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileWritePermissions
‪assureFileWritePermissions(FileInterface $file)
Definition: ResourceStorage.php:933
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\REPLACE
‪const REPLACE
Definition: DuplicationBehavior.php:39
‪TYPO3\CMS\Core\Resource\ResourceInterface
Definition: ResourceInterface.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWritable
‪bool isWritable()
Definition: ResourceStorage.php:403
‪TYPO3\CMS\Core\Resource\Folder\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: Folder.php:181
‪TYPO3\CMS\Core\Resource\ResourceStorage\$userPermissions
‪array $userPermissions
Definition: ResourceStorage.php:168
‪TYPO3\CMS\Core\Resource\Service\FileProcessingService
Definition: FileProcessingService.php:38
‪TYPO3\CMS\Core\Resource\ResourceStorage\isFallbackStorage
‪isFallbackStorage()
Definition: ResourceStorage.php:351
‪TYPO3\CMS\Core\Resource\Event\SanitizeFileNameEvent
Definition: SanitizeFileNameEvent.php:29
‪TYPO3\CMS\Core\Resource\AbstractFile\updateProperties
‪updateProperties(array $properties)
‪TYPO3\CMS\Core\Resource\ResourceStorage\getResourceFactoryInstance
‪ResourceFactory getResourceFactoryInstance()
Definition: ResourceStorage.php:2938
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Resource\ResourceStorage\unsetFileAndFolderNameFilters
‪unsetFileAndFolderNameFilters()
Definition: ResourceStorage.php:1527
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface\setStorageUid
‪setStorageUid($storageUid)
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderMovedEvent
Definition: BeforeFolderMovedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileActionPermission
‪bool checkFileActionPermission($action, FileInterface $file)
Definition: ResourceStorage.php:715
‪TYPO3\CMS\Core\Resource\FileInterface\getMimeType
‪string getMimeType()
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath($targetPath, bool $prefixWithSitePath=true)
Definition: PathUtility.php:51
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException
Definition: FileOperationErrorException.php:21
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderIdentifiersInFolder
‪array getFolderIdentifiersInFolder($folderIdentifier, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1679
‪TYPO3\CMS\Core\Resource\Event\AfterFileReplacedEvent
Definition: AfterFileReplacedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkUserActionPermission
‪bool checkUserActionPermission($action, $type)
Definition: ResourceStorage.php:688
‪TYPO3\CMS\Core\Resource\Event\AfterFolderDeletedEvent
Definition: AfterFolderDeletedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceInterface\getParentFolder
‪FolderInterface getParentFolder()
‪TYPO3\CMS\Core\Resource\ResourceStorage\updateProcessedFile
‪FileInterface updateProcessedFile($localFilePath, ProcessedFile $processedFile, ?Folder $processingFolder=null)
Definition: ResourceStorage.php:1303
‪TYPO3\CMS\Core\Resource\Service\FileProcessingService\processFile
‪Resource ProcessedFile processFile(FileInterface $fileObject, ResourceStorage $targetStorage, $taskType, $configuration)
Definition: FileProcessingService.php:76
‪TYPO3\CMS\Core\Resource\Event\AfterFileDeletedEvent
Definition: AfterFileDeletedEvent.php:29
‪TYPO3\CMS\Core\Resource\Driver\StreamableDriverInterface
Definition: StreamableDriverInterface.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUniqueName
‪string getUniqueName(FolderInterface $folder, $theFile, $dontCheckForUnique=false)
Definition: ResourceStorage.php:2678
‪TYPO3\CMS\Core\Resource\ResourceStorage\deleteFile
‪bool deleteFile($fileObject)
Definition: ResourceStorage.php:1898
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderDeletePermission
‪assureFolderDeletePermission(Folder $folder, $checkDeleteRecursively)
Definition: ResourceStorage.php:881
‪TYPO3\CMS\Core\Resource\Exception\InvalidHashException
Definition: InvalidHashException.php:26
‪TYPO3\CMS\Core\Resource\Event\BeforeFileContentsSetEvent
Definition: BeforeFileContentsSetEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\getIndexer
‪Index Indexer getIndexer()
Definition: ResourceStorage.php:2914
‪TYPO3\CMS\Core\Resource\Folder\hasFolder
‪bool hasFolder($name)
Definition: Folder.php:425
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFolderInFolder
‪bool hasFolderInFolder($folderName, Folder $folder)
Definition: ResourceStorage.php:2504
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileIndexRepository
‪Index FileIndexRepository getFileIndexRepository()
Definition: ResourceStorage.php:2724
‪TYPO3\CMS\Core\Resource\ResourceStorage\copyFolder
‪Folder copyFolder(FolderInterface $folderToCopy, FolderInterface $targetParentFolder, $newFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2288
‪TYPO3\CMS\Core\Resource\ProcessedFile\getName
‪string getName()
Definition: ProcessedFile.php:333
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_WRITABLE
‪const CAPABILITY_WRITABLE
Definition: ResourceStorageInterface.php:35
‪TYPO3\CMS\Core\Resource\Event\AfterFileAddedEvent
Definition: AfterFileAddedEvent.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\setDefault
‪setDefault($isDefault)
Definition: ResourceStorage.php:2922
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository\findOneByStorageAndIdentifier
‪array bool findOneByStorageAndIdentifier(ResourceStorage $storage, $identifier)
Definition: FileIndexRepository.php:136
‪TYPO3\CMS\Core\Resource\ResourceStorage\getName
‪string getName()
Definition: ResourceStorage.php:320
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileMounts
‪array $fileMounts
Definition: ResourceStorage.php:161
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileUploadPermissions
‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileSize)
Definition: ResourceStorage.php:1034
‪TYPO3\CMS\Core\Resource\AbstractFile\getStorage
‪ResourceStorage getStorage()
Definition: AbstractFile.php:395
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderReadPermission
‪assureFolderReadPermission(?Folder $folder=null)
Definition: ResourceStorage.php:856
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNestedProcessingFolder
‪Folder getNestedProcessingFolder(File $file, Folder $rootProcessingFolder)
Definition: ResourceStorage.php:2854