‪TYPO3CMS  ‪main
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;
30 use TYPO3\CMS\Core\Resource\Driver\DriverInterface;
93 
127 {
133  protected ‪$driver;
134 
140  protected ‪$storageRecord;
141 
147  protected ‪$configuration;
148 
152  protected ‪$fileProcessingService;
153 
162  protected ‪$evaluatePermissions = false;
163 
169  protected ‪$fileMounts = [];
170 
177  protected ‪$userPermissions = [];
178 
183 
187  protected ‪$eventDispatcher;
188 
192  protected ‪$processingFolder;
193 
200 
206  protected ‪$isOnline;
207 
211  protected ‪$isDefault = false;
212 
219 
223  public const ‪PROCESSING_FOLDER_LEVELS = 2;
224 
231  public function ‪__construct(DriverInterface ‪$driver, array ‪$storageRecord, EventDispatcherInterface ‪$eventDispatcher = null)
232  {
233  if (!isset(‪$storageRecord['uid'])) {
234  throw new \InvalidArgumentException(
235  '$storageRecord[\'uid\'] is unexpectedly not set',
236  1688920972
237  );
238  }
239 
240  $this->storageRecord = ‪$storageRecord;
241  $this->eventDispatcher = ‪$eventDispatcher ?? GeneralUtility::makeInstance(EventDispatcherInterface::class);
242  if (is_array(‪$storageRecord['configuration'] ?? null)) {
243  $this->configuration = ‪$storageRecord['configuration'];
244  } elseif (!empty(‪$storageRecord['configuration'] ?? '')) {
245  $this->configuration = GeneralUtility::makeInstance(FlexFormService::class)->convertFlexFormContentToArray(‪$storageRecord['configuration']);
246  } else {
247  $this->configuration = [];
248  }
249 
250  $capabilityBits = 0;
251  $capabilityBits += ($this->storageRecord['is_browsable'] ?? null ? ‪Capabilities::CAPABILITY_BROWSABLE : 0);
252  $capabilityBits += ($this->storageRecord['is_public'] ?? null ? ‪Capabilities::CAPABILITY_PUBLIC : 0);
253  $capabilityBits += ($this->storageRecord['is_writable'] ?? null ? ‪Capabilities::CAPABILITY_WRITABLE : 0);
254  // Always let the driver decide whether to set this capability
256 
257  $this->capabilities = new ‪Capabilities($capabilityBits);
258 
259  $this->driver = ‪$driver;
260  $this->driver->setStorageUid((int)‪$storageRecord['uid']);
261  $this->driver->mergeConfigurationCapabilities($this->capabilities);
262  try {
263  $this->driver->processConfiguration();
264  } catch (‪InvalidConfigurationException $e) {
265  // Configuration error
266  $this->‪isOnline = false;
267 
268  $message = sprintf(
269  'Failed initializing storage [%d] "%s", error: %s',
270  $this->‪getUid(),
271  $this->‪getName(),
272  $e->getMessage()
273  );
274 
275  // create a dedicated logger instance because we need a logger in the constructor
276  GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class)->error($message);
277  }
278  $this->driver->initialize();
279  $this->capabilities = $this->driver->getCapabilities();
280 
281  $this->‪isDefault = (isset(‪$storageRecord['is_default']) && ‪$storageRecord['is_default'] == 1);
283  }
284 
290  public function ‪getConfiguration()
291  {
293  }
294 
298  public function ‪setConfiguration(array ‪$configuration)
299  {
300  $this->configuration = ‪$configuration;
301  }
302 
308  public function ‪getStorageRecord()
309  {
311  }
312 
318  public function ‪setDriver(DriverInterface ‪$driver)
319  {
320  $this->driver = ‪$driver;
321  return ‪$this;
322  }
323 
329  protected function ‪getDriver()
330  {
331  return ‪$this->driver;
332  }
333 
339  public function ‪getName()
340  {
341  return $this->storageRecord['name'];
342  }
343 
349  public function ‪getUid()
350  {
351  return (int)($this->storageRecord['uid'] ?? 0);
352  }
353 
359  public function ‪hasChildren()
360  {
361  return true;
362  }
363 
364  /*********************************
365  * Capabilities
366  ********************************/
370  public function ‪getCapabilities(): Capabilities
371  {
372  return ‪$this->capabilities;
373  }
374 
380  protected function ‪hasCapability(int $capability): bool
381  {
382  return $this->capabilities->hasCapability($capability);
383  }
384 
393  public function ‪isPublic()
394  {
396  }
397 
404  public function ‪isWritable()
405  {
407  }
408 
414  public function ‪isBrowsable()
415  {
417  }
418 
422  public function ‪hasHierarchicalIdentifiers(): bool
423  {
425  }
426 
434  public function ‪searchFiles(FileSearchDemand $searchDemand, Folder $folder = null, bool $useFilters = true): FileSearchResultInterface
435  {
436  $folder = $folder ?? $this->‪getRootLevelFolder();
437  if (!$folder->‪checkActionPermission('read')) {
438  return new EmptyFileSearchResult();
439  }
440 
441  return new DriverFilteredSearchResult(
443  $searchDemand->withFolder($folder)
444  ),
445  ‪$this->driver,
446  $useFilters ? ‪$this->getFileAndFolderNameFilters() : []
447  );
448  }
449 
455  public function ‪usesCaseSensitiveIdentifiers()
456  {
457  return $this->driver->isCaseSensitiveFileSystem();
458  }
459 
465  public function ‪isOnline()
466  {
467  if ($this->‪isOnline === null) {
468  if ($this->‪getUid() === 0) {
469  $this->‪isOnline = true;
470  }
471  // the storage is not marked as online for a longer time
472  if ($this->storageRecord['is_online'] == 0) {
473  $this->‪isOnline = false;
474  }
475  if ($this->‪isOnline !== false) {
476  if ((‪$GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
477  && ‪ApplicationType::fromRequest(‪$GLOBALS['TYPO3_REQUEST'])->isFrontend()
478  ) {
479  // All files are ALWAYS available in the frontend
480  $this->‪isOnline = true;
481  } else {
482  // check if the storage is disabled temporary for now
483  $registryObject = GeneralUtility::makeInstance(Registry::class);
484  $offlineUntil = $registryObject->get('core', 'sys_file_storage-' . $this->‪getUid() . '-offline-until');
485  if ($offlineUntil && $offlineUntil > time()) {
486  $this->‪isOnline = false;
487  } else {
488  $this->‪isOnline = true;
489  }
490  }
491  }
492  }
493  return ‪$this->isOnline;
494  }
495 
501  public function ‪autoExtractMetadataEnabled()
502  {
503  return !empty($this->storageRecord['auto_extract_metadata']);
504  }
505 
513  public function ‪markAsPermanentlyOffline()
514  {
515  if ($this->‪getUid() > 0) {
516  // @todo: move this to the storage repository
517  GeneralUtility::makeInstance(ConnectionPool::class)
518  ->getConnectionForTable('sys_file_storage')
519  ->update(
520  'sys_file_storage',
521  ['is_online' => 0],
522  ['uid' => (int)$this->‪getUid()]
523  );
524  }
525  $this->storageRecord['is_online'] = 0;
526  $this->‪isOnline = false;
527  }
528 
535  public function ‪markAsTemporaryOffline()
536  {
537  $registryObject = GeneralUtility::makeInstance(Registry::class);
538  $registryObject->set('core', 'sys_file_storage-' . $this->‪getUid() . '-offline-until', time() + 60 * 5);
539  $this->storageRecord['is_online'] = 0;
540  $this->‪isOnline = false;
541  }
542 
543  /*********************************
544  * User Permissions / File Mounts
545  ********************************/
555  public function ‪addFileMount($folderIdentifier, $additionalData = [])
556  {
557  // check for the folder before we add it as a filemount
558  if ($this->driver->folderExists($folderIdentifier) === false) {
559  // if there is an error, this is important and should be handled
560  // as otherwise the user would see the whole storage without any restrictions for the filemounts
561  throw new ‪FolderDoesNotExistException('Folder for file mount ' . $folderIdentifier . ' does not exist.', 1334427099);
562  }
563  $data = $this->driver->getFolderInfoByIdentifier($folderIdentifier);
564  $folderObject = $this->‪createFolderObject($data['identifier'], $data['name']);
565  // Use the canonical identifier instead of the user provided one!
566  $folderIdentifier = $folderObject->getIdentifier();
567  if (
568  !empty($this->fileMounts[$folderIdentifier])
569  && empty($this->fileMounts[$folderIdentifier]['read_only'])
570  && !empty($additionalData['read_only'])
571  ) {
572  // Do not overwrite a regular mount with a read only mount
573  return;
574  }
575  if (empty($additionalData)) {
576  $additionalData = [
577  'path' => $folderIdentifier,
578  'title' => $folderIdentifier,
579  'folder' => $folderObject,
580  ];
581  } else {
582  $additionalData['folder'] = $folderObject;
583  if (!isset($additionalData['title'])) {
584  $additionalData['title'] = $folderIdentifier;
585  }
586  }
587  $this->fileMounts[$folderIdentifier] = $additionalData;
588  }
589 
595  public function ‪getFileMounts()
596  {
597  return ‪$this->fileMounts;
598  }
599 
608  public function ‪isWithinFileMountBoundaries($subject, $checkWriteAccess = false)
609  {
610  if (!$this->evaluatePermissions) {
611  return true;
612  }
613  $isWithinFileMount = false;
614  if (!$subject) {
615  $subject = $this->‪getRootLevelFolder();
616  }
617  ‪$identifier = $subject->getIdentifier();
618 
619  // Allow access to processing folder
621  $isWithinFileMount = true;
622  } else {
623  // Check if the identifier of the subject is within at
624  // least one of the file mounts
625  $writableFileMountAvailable = false;
626  foreach ($this->fileMounts as $fileMount) {
628  $folder = $fileMount['folder'];
629  if ($this->driver->isWithin($folder->‪getIdentifier(), ‪$identifier)) {
630  $isWithinFileMount = true;
631  if (!$checkWriteAccess) {
632  break;
633  }
634  if (empty($fileMount['read_only'])) {
635  $writableFileMountAvailable = true;
636  break;
637  }
638  }
639  }
640  $isWithinFileMount = $checkWriteAccess ? $writableFileMountAvailable : $isWithinFileMount;
641  }
642  return $isWithinFileMount;
643  }
644 
652  {
653  $this->evaluatePermissions = (bool)‪$evaluatePermissions;
654  }
655 
662  public function ‪getEvaluatePermissions()
663  {
665  }
666 
671  {
672  $this->userPermissions = ‪$userPermissions;
673  }
674 
683  public function ‪checkUserActionPermission($action, $type)
684  {
685  if (!$this->evaluatePermissions) {
686  return true;
687  }
688 
689  $allow = false;
690  if (!empty($this->userPermissions[strtolower($action) . ucfirst(strtolower($type))])) {
691  $allow = true;
692  }
693 
694  return $allow;
695  }
696 
709  public function ‪checkFileActionPermission($action, ‪FileInterface $file)
710  {
711  $isProcessedFile = $file instanceof ‪ProcessedFile;
712  // Check 1: Allow editing meta data of a file if it is in mount boundaries of a writable file mount
713  if ($action === 'editMeta') {
714  return !$isProcessedFile && $this->‪isWithinFileMountBoundaries($file, true);
715  }
716  // Check 2: Does the user have permission to perform the action? e.g. "readFile"
717  if (!$isProcessedFile && $this->‪checkUserActionPermission($action, 'File') === false) {
718  return false;
719  }
720  // Check 3: No action allowed on files for denied file extensions
721  if (!$this->‪checkFileExtensionPermission($file->‪getName())) {
722  return false;
723  }
724  $isReadCheck = false;
725  if (in_array($action, ['read', 'copy', 'move', 'replace'], true)) {
726  $isReadCheck = true;
727  }
728  $isWriteCheck = false;
729  if (in_array($action, ['add', 'write', 'move', 'rename', 'replace', 'delete'], true)) {
730  $isWriteCheck = true;
731  }
732  // Check 4: Does the user have the right to perform the action?
733  // (= is he within the file mount borders)
734  if (!$isProcessedFile && !$this->‪isWithinFileMountBoundaries($file, $isWriteCheck)) {
735  return false;
736  }
737 
738  $isMissing = false;
739  if (!$isProcessedFile && $file instanceof ‪File) {
740  $isMissing = $file->isMissing();
741  }
742 
743  if ($this->driver->fileExists($file->‪getIdentifier()) === false) {
744  $file->setMissing(true);
745  $isMissing = true;
746  }
747 
748  // Check 5: Check the capabilities of the storage (and the driver)
749  if ($isWriteCheck && ($isMissing || !$this->‪isWritable())) {
750  return false;
751  }
752 
753  // Check 6: "File permissions" of the driver (only when file isn't marked as missing)
754  if (!$isMissing) {
755  $filePermissions = $this->driver->getPermissions($file->‪getIdentifier());
756  if ($isReadCheck && !$filePermissions['r']) {
757  return false;
758  }
759  if ($isWriteCheck && !$filePermissions['w']) {
760  return false;
761  }
762  }
763  return true;
764  }
765 
776  public function ‪checkFolderActionPermission($action, ‪Folder $folder = null)
777  {
778  // Check 1: Does the user have permission to perform the action? e.g. "writeFolder"
779  if ($this->‪checkUserActionPermission($action, 'Folder') === false) {
780  return false;
781  }
782 
783  // If we do not have a folder here, we cannot do further checks
784  if ($folder === null) {
785  return true;
786  }
787 
788  $isReadCheck = false;
789  if (in_array($action, ['read', 'copy'], true)) {
790  $isReadCheck = true;
791  }
792  $isWriteCheck = false;
793  if (in_array($action, ['add', 'move', 'write', 'delete', 'rename'], true)) {
794  $isWriteCheck = true;
795  }
796  // Check 2: Does the user has the right to perform the action?
797  // (= is he within the file mount borders)
798  if (!$this->‪isWithinFileMountBoundaries($folder, $isWriteCheck)) {
799  return false;
800  }
801  // Check 3: Check the capabilities of the storage (and the driver)
802  if ($isReadCheck && !$this->‪isBrowsable()) {
803  return false;
804  }
805  if ($isWriteCheck && !$this->‪isWritable()) {
806  return false;
807  }
808 
809  // Check 4: "Folder permissions" of the driver
810  $folderPermissions = $this->driver->getPermissions($folder->‪getIdentifier());
811  if ($isReadCheck && !$folderPermissions['r']) {
812  return false;
813  }
814  if ($isWriteCheck && !$folderPermissions['w']) {
815  return false;
816  }
817  return true;
818  }
819 
827  protected function ‪checkFileExtensionPermission($fileName)
828  {
829  $fileName = $this->driver->sanitizeFileName($fileName);
830  return GeneralUtility::makeInstance(FileNameValidator::class)->isValid($fileName);
831  }
832 
839  protected function ‪assureFolderReadPermission(Folder $folder = null)
840  {
841  if (!$this->‪checkFolderActionPermission('read', $folder)) {
842  if ($folder === null) {
843  throw new InsufficientFolderAccessPermissionsException(
844  'You are not allowed to read folders',
845  1430657869
846  );
847  }
848  throw new InsufficientFolderAccessPermissionsException(
849  'You are not allowed to access the given folder: "' . $folder->‪getName() . '"',
850  1375955684
851  );
852  }
853  }
854 
864  protected function ‪assureFolderDeletePermission(Folder $folder, $checkDeleteRecursively)
865  {
866  // Check user permissions for recursive deletion if it is requested
867  if ($checkDeleteRecursively && !$this->‪checkUserActionPermission('recursivedelete', 'Folder')) {
868  throw new InsufficientUserPermissionsException('You are not allowed to delete folders recursively', 1377779423);
869  }
870  // Check user action permission
871  if (!$this->‪checkFolderActionPermission('delete', $folder)) {
872  throw new InsufficientFolderAccessPermissionsException(
873  'You are not allowed to delete the given folder: "' . $folder->getName() . '"',
874  1377779039
875  );
876  }
877  // Check if the user has write permissions to folders
878  // Would be good if we could check for actual write permissions in the containing folder
879  // but we cannot since we have no access to the containing folder of this file.
880  if (!$this->‪checkUserActionPermission('write', 'Folder')) {
881  throw new ‪InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377779111);
882  }
883  }
884 
891  protected function ‪assureFileReadPermission(FileInterface $file)
892  {
893  if (!$this->‪checkFileActionPermission('read', $file)) {
894  throw new InsufficientFileAccessPermissionsException(
895  'You are not allowed to access that file: "' . $file->getName() . '"',
896  1375955429
897  );
898  }
899  if (!$this->‪checkFileExtensionPermission($file->getName())) {
900  throw new IllegalFileExtensionException(
901  'You are not allowed to use that file extension. File: "' . $file->getName() . '"',
902  1375955430
903  );
904  }
905  }
906 
914  protected function ‪assureFileWritePermissions(FileInterface $file)
915  {
916  // Check if user is allowed to write the file and $file is writable
917  if (!$this->‪checkFileActionPermission('write', $file)) {
918  throw new ‪InsufficientFileWritePermissionsException('Writing to file "' . $file->getIdentifier() . '" is not allowed.', 1330121088);
919  }
920  if (!$this->‪checkFileExtensionPermission($file->getName())) {
921  throw new ‪IllegalFileExtensionException('You are not allowed to edit a file with extension "' . $file->getExtension() . '"', 1366711933);
922  }
923  }
924 
931  protected function ‪assureFileReplacePermissions(FileInterface $file)
932  {
933  // Check if user is allowed to replace the file and $file is writable
934  if (!$this->‪checkFileActionPermission('replace', $file)) {
935  throw new InsufficientFileWritePermissionsException('Replacing file "' . $file->getIdentifier() . '" is not allowed.', 1436899571);
936  }
937  // Check if parentFolder is writable for the user
938  if (!$this->‪checkFolderActionPermission('write', $file->getParentFolder())) {
939  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $file->getIdentifier() . '"', 1436899572);
940  }
941  }
942 
950  protected function ‪assureFileDeletePermissions(FileInterface $file)
951  {
952  // Check for disallowed file extensions
953  if (!$this->‪checkFileExtensionPermission($file->getName())) {
954  throw new IllegalFileExtensionException('You are not allowed to delete a file with extension "' . $file->getExtension() . '"', 1377778916);
955  }
956  // Check further permissions if file is not a processed file
957  if (!$file instanceof ProcessedFile) {
958  // Check if user is allowed to delete the file and $file is writable
959  if (!$this->‪checkFileActionPermission('delete', $file)) {
960  // Do not throw exception, if file is just missing.
961  // That way we make sure event "FileDeletionAspect" is still being called to remove the remaining records.
962  if ($file instanceof File && $file->isMissing()) {
963  return;
964  }
965  throw new InsufficientFileWritePermissionsException('You are not allowed to delete the file "' . $file->getIdentifier() . '"', 1319550425);
966  }
967  // Check if the user has write permissions to folders
968  // Would be good if we could check for actual write permissions in the containing folder
969  // but we cannot since we have no access to the containing folder of this file.
970  if (!$this->‪checkUserActionPermission('write', 'Folder')) {
971  throw new InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377778702);
972  }
973  }
974  }
975 
987  protected function ‪assureFileAddPermissions($targetFolder, $targetFileName)
988  {
989  // Check for a valid file extension
990  if (!$this->‪checkFileExtensionPermission($targetFileName)) {
991  throw new ‪IllegalFileExtensionException('Extension of file name is not allowed in "' . $targetFileName . '"!', 1322120271);
992  }
993  // Makes sure the user is allowed to upload
994  if (!$this->‪checkUserActionPermission('add', 'File')) {
995  throw new InsufficientUserPermissionsException('You are not allowed to add files to this storage "' . $this->‪getUid() . '"', 1376992145);
996  }
997  // Check if targetFolder is writable
998  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
999  throw new InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetFolder->getIdentifier() . '"', 1322120356);
1000  }
1001  }
1002 
1018  protected function ‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileSize)
1019  {
1020  // Makes sure this is an uploaded file
1021  if (!is_uploaded_file($localFilePath)) {
1022  throw new UploadException('The upload has failed, no uploaded file found!', 1322110455);
1023  }
1024  // Max upload size (kb) for files.
1025  $maxUploadFileSize = GeneralUtility::getMaxUploadFileSize() * 1024;
1026  if ($maxUploadFileSize > 0 && $uploadedFileSize >= $maxUploadFileSize) {
1027  unlink($localFilePath);
1028  throw new UploadSizeException('The uploaded file exceeds the size-limit of ' . $maxUploadFileSize . ' bytes', 1322110041);
1029  }
1030  $this->‪assureFileAddPermissions($targetFolder, $targetFileName);
1031  }
1032 
1042  protected function ‪assureFileMovePermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
1043  {
1044  // Check if targetFolder is within this storage
1045  if ($this->‪getUid() !== $targetFolder->getStorage()->getUid()) {
1046  throw new \RuntimeException('The target folder is not in the same storage. Target folder given: "' . $targetFolder->getIdentifier() . '"', 1422553107);
1047  }
1048  // Check for a valid file extension
1049  if (!$this->‪checkFileExtensionPermission($targetFileName)) {
1050  throw new IllegalFileExtensionException('Extension of file name is not allowed in "' . $targetFileName . '"!', 1378243279);
1051  }
1052  // Check if user is allowed to move and $file is readable and writable
1053  if (!$file->getStorage()->checkFileActionPermission('move', $file)) {
1054  throw new InsufficientUserPermissionsException('You are not allowed to move files to storage "' . $this->‪getUid() . '"', 1319219349);
1055  }
1056  // Check if target folder is writable
1057  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1058  throw new ‪InsufficientFolderAccessPermissionsException('You are not allowed to write to the target folder "' . $targetFolder->getIdentifier() . '"', 1319219350);
1059  }
1060  }
1061 
1071  protected function ‪assureFileRenamePermissions(FileInterface $file, $targetFileName)
1072  {
1073  // Check if file extension is allowed
1074  if (!$this->‪checkFileExtensionPermission($targetFileName) || !$this->‪checkFileExtensionPermission($file->getName())) {
1075  throw new IllegalFileExtensionException('You are not allowed to rename a file with this extension. File given: "' . $file->getName() . '"', 1371466663);
1076  }
1077  // Check if user is allowed to rename
1078  if (!$this->‪checkFileActionPermission('rename', $file)) {
1079  throw new InsufficientUserPermissionsException('You are not allowed to rename files. File given: "' . $file->getName() . '"', 1319219351);
1080  }
1081  // Check if the user is allowed to write to folders
1082  // Although it would be good to check, we cannot check here if the folder actually is writable
1083  // because we do not know in which folder the file resides.
1084  // So we rely on the driver to throw an exception in case the renaming failed.
1085  if (!$this->‪checkFolderActionPermission('write')) {
1086  throw new InsufficientFileWritePermissionsException('You are not allowed to write to folders', 1319219352);
1087  }
1088  }
1102  protected function ‪assureFileCopyPermissions(‪FileInterface $file, ‪Folder $targetFolder, $targetFileName)
1103  {
1104  // Check if targetFolder is within this storage, this should never happen
1105  if ($this->‪getUid() != $targetFolder->‪getStorage()->getUid()) {
1106  throw new ‪Exception('The operation of the folder cannot be called by this storage "' . $this->‪getUid() . '"', 1319550405);
1107  }
1108  // Check if user is allowed to copy
1109  if (!$file->‪getStorage()->checkFileActionPermission('copy', $file)) {
1110  throw new ‪InsufficientFileReadPermissionsException('You are not allowed to copy the file "' . $file->‪getIdentifier() . '"', 1319550426);
1111  }
1112  // Check if targetFolder is writable
1113  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1114  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetFolder->‪getIdentifier() . '"', 1319550435);
1115  }
1116  // Check for a valid file extension
1117  if (!$this->‪checkFileExtensionPermission($targetFileName) || !$this->‪checkFileExtensionPermission($file->‪getName())) {
1118  throw new ‪IllegalFileExtensionException('You are not allowed to copy a file of that type.', 1319553317);
1119  }
1120  }
1134  protected function ‪assureFolderCopyPermissions(‪FolderInterface $folderToCopy, ‪FolderInterface $targetParentFolder)
1135  {
1136  // Check if targetFolder is within this storage, this should never happen
1137  if ($this->‪getUid() !== $targetParentFolder->‪getStorage()->getUid()) {
1138  throw new ‪Exception('The operation of the folder cannot be called by this storage "' . $this->‪getUid() . '"', 1377777624);
1139  }
1140  if (!$folderToCopy instanceof ‪Folder) {
1141  throw new \RuntimeException('The folder "' . $folderToCopy->‪getIdentifier() . '" to copy is not of type folder.', 1384209020);
1142  }
1143  // Check if user is allowed to copy and the folder is readable
1144  if (!$folderToCopy->‪getStorage()->checkFolderActionPermission('copy', $folderToCopy)) {
1145  throw new ‪InsufficientFileReadPermissionsException('You are not allowed to copy the folder "' . $folderToCopy->‪getIdentifier() . '"', 1377777629);
1146  }
1147  if (!$targetParentFolder instanceof ‪Folder) {
1148  throw new \RuntimeException('The target folder "' . $targetParentFolder->‪getIdentifier() . '" is not of type folder.', 1384209021);
1149  }
1150  // Check if targetFolder is writable
1151  if (!$this->‪checkFolderActionPermission('write', $targetParentFolder)) {
1152  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetParentFolder->‪getIdentifier() . '"', 1377777635);
1153  }
1154  }
1168  protected function ‪assureFolderMovePermissions(‪FolderInterface $folderToMove, ‪FolderInterface $targetParentFolder)
1169  {
1170  // Check if targetFolder is within this storage, this should never happen
1171  if ($this->‪getUid() !== $targetParentFolder->‪getStorage()->getUid()) {
1172  throw new \InvalidArgumentException('Cannot move a folder into a folder that does not belong to this storage.', 1325777289);
1173  }
1174  if (!$folderToMove instanceof ‪Folder) {
1175  throw new \RuntimeException('The folder "' . $folderToMove->‪getIdentifier() . '" to move is not of type Folder.', 1384209022);
1176  }
1177  // Check if user is allowed to move and the folder is writable
1178  // In fact we would need to check if the parent folder of the folder to move is writable also
1179  // But as of now we cannot extract the parent folder from this folder
1180  if (!$folderToMove->‪getStorage()->checkFolderActionPermission('move', $folderToMove)) {
1181  throw new ‪InsufficientFileReadPermissionsException('You are not allowed to copy the folder "' . $folderToMove->‪getIdentifier() . '"', 1377778045);
1182  }
1183  if (!$targetParentFolder instanceof ‪Folder) {
1184  throw new \RuntimeException('The target folder "' . $targetParentFolder->‪getIdentifier() . '" is not of type Folder.', 1384209023);
1185  }
1186  // Check if targetFolder is writable
1187  if (!$this->‪checkFolderActionPermission('write', $targetParentFolder)) {
1188  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetParentFolder->‪getIdentifier() . '"', 1377778049);
1189  }
1190  }
1191 
1200  public function ‪sanitizeFileName($fileName, Folder $targetFolder = null)
1201  {
1202  $targetFolder = $targetFolder ?: $this->‪getDefaultFolder();
1203  $fileName = $this->driver->sanitizeFileName($fileName);
1204 
1205  // The file name could be changed by an event listener
1206  $fileName = $this->eventDispatcher->dispatch(
1207  new SanitizeFileNameEvent($fileName, $targetFolder, ‪$this, $this->driver)
1208  )->getFileName();
1209 
1210  return $fileName;
1211  }
1212 
1213  /********************
1214  * FILE ACTIONS
1215  ********************/
1229  public function ‪addFile($localFilePath, Folder $targetFolder, $targetFileName = '', $conflictMode = ‪DuplicationBehavior::RENAME, $removeOriginal = true)
1230  {
1231  $localFilePath = ‪PathUtility::getCanonicalPath($localFilePath);
1232  // File is not available locally NOR is it an uploaded file
1233  if (!is_uploaded_file($localFilePath) && !file_exists($localFilePath)) {
1234  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552745);
1235  }
1236  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
1237  $targetFileName = $this->‪sanitizeFileName($targetFileName ?: ‪PathUtility::basename($localFilePath), $targetFolder);
1238 
1239  $targetFileName = $this->eventDispatcher->dispatch(
1240  new BeforeFileAddedEvent($targetFileName, $localFilePath, $targetFolder, ‪$this, $this->driver)
1241  )->getFileName();
1242 
1243  $this->‪assureFileAddPermissions($targetFolder, $targetFileName);
1244 
1245  $replaceExisting = false;
1246  if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && ‪$this->driver->fileExistsInFolder($targetFileName, $targetFolder->getIdentifier())) {
1247  throw new ExistingTargetFileNameException('File "' . $targetFileName . '" already exists in folder ' . $targetFolder->getIdentifier(), 1322121068);
1248  }
1249  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
1250  $targetFileName = $this->‪getUniqueName($targetFolder, $targetFileName);
1251  } elseif ($conflictMode->equals(‪DuplicationBehavior::REPLACE) && ‪$this->driver->fileExistsInFolder($targetFileName, $targetFolder->getIdentifier())) {
1252  $replaceExisting = true;
1253  }
1254 
1255  $fileIdentifier = $this->driver->addFile($localFilePath, $targetFolder->getIdentifier(), $targetFileName, $removeOriginal);
1256  $file = $this->‪getFileByIdentifier($fileIdentifier);
1257 
1258  if ($replaceExisting && $file instanceof File) {
1259  $this->‪getIndexer()->‪updateIndexEntry($file);
1260  }
1261 
1262  $this->eventDispatcher->dispatch(
1263  new ‪AfterFileAddedEvent($file, $targetFolder)
1264  );
1265  return $file;
1266  }
1267 
1276  public function ‪updateProcessedFile($localFilePath, ‪ProcessedFile $processedFile, ‪Folder ‪$processingFolder = null)
1277  {
1278  if (!file_exists($localFilePath)) {
1279  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552746);
1280  }
1281  if (‪$processingFolder === null) {
1283  }
1284  $fileIdentifier = $this->driver->addFile($localFilePath, ‪$processingFolder->‪getIdentifier(), $processedFile->‪getName());
1285  // @todo check if we have to update the processed file other then the identifier
1286  $processedFile->‪setIdentifier($fileIdentifier);
1287  return $processedFile;
1288  }
1289 
1297  public function ‪hashFile(‪FileInterface $fileObject, $hash)
1298  {
1299  return $this->‪hashFileByIdentifier($fileObject->‪getIdentifier(), $hash);
1300  }
1301 
1310  public function ‪hashFileByIdentifier($fileIdentifier, $hash)
1311  {
1312  $hash = $this->driver->hash($fileIdentifier, $hash);
1313  if (!is_string($hash) || $hash === '') {
1314  throw new ‪InvalidHashException('Hash has to be non-empty string.', 1551950301);
1315  }
1316  return $hash;
1317  }
1318 
1327  public function ‪hashFileIdentifier($file)
1328  {
1329  if ($file instanceof FileInterface) {
1331  $file = $file->getIdentifier();
1332  }
1333  return $this->driver->hashIdentifier($file);
1334  }
1335 
1345  public function ‪getPublicUrl(ResourceInterface $resourceObject)
1346  {
1347  ‪$publicUrl = null;
1348  if ($this->‪isOnline()) {
1349  // Pre-process the public URL by an accordant event
1350  $event = new GeneratePublicUrlForResourceEvent($resourceObject, ‪$this, $this->driver);
1351  ‪$publicUrl = $this->eventDispatcher->dispatch($event)->getPublicUrl();
1352  if (
1353  ‪$publicUrl === null
1354  && $resourceObject instanceof File
1355  && ($helper = GeneralUtility::makeInstance(OnlineMediaHelperRegistry::class)->getOnlineMediaHelper($resourceObject)) !== false
1356  ) {
1357  ‪$publicUrl = $helper->getPublicUrl($resourceObject);
1358  }
1359 
1360  // If an event listener did not handle the URL generation, use the default way to determine public URL
1361  if (‪$publicUrl === null) {
1363  ‪$publicUrl = $this->driver->getPublicUrl($resourceObject->getIdentifier());
1364  }
1365 
1366  if (‪$publicUrl === null && $resourceObject instanceof FileInterface) {
1367  $queryParameterArray = ['eID' => 'dumpFile', 't' => ''];
1368  if ($resourceObject instanceof File) {
1369  $queryParameterArray['f'] = $resourceObject->getUid();
1370  $queryParameterArray['t'] = 'f';
1371  } elseif ($resourceObject instanceof ProcessedFile) {
1372  $queryParameterArray['p'] = $resourceObject->getUid();
1373  $queryParameterArray['t'] = 'p';
1374  }
1376  $queryParameterArray['token'] = ‪GeneralUtility::hmac(implode('|', $queryParameterArray), 'resourceStorageDumpFile');
1377  ‪$publicUrl = GeneralUtility::locationHeaderUrl(‪PathUtility::getAbsoluteWebPath(‪Environment::getPublicPath() . '/index.php'));
1378  ‪$publicUrl .= '?' . http_build_query($queryParameterArray, '', '&', PHP_QUERY_RFC3986);
1379  }
1380  }
1381  }
1382  return ‪$publicUrl;
1383  }
1384 
1388  public function ‪processFile(File|FileReference $fileObject, string $context, array ‪$configuration): ProcessedFile
1389  {
1390  if ($fileObject->getStorage() !== ‪$this) {
1391  throw new \InvalidArgumentException('Cannot process files of foreign storage', 1353401835);
1392  }
1393  return $this->‪getFileProcessingService()->‪processFile($fileObject, $context, $this->driver, ‪$configuration);
1394  }
1395 
1402  public function ‪getFileForLocalProcessing(‪FileInterface $fileObject, $writable = true)
1403  {
1404  $filePath = $this->driver->getFileForLocalProcessing($fileObject->‪getIdentifier(), $writable);
1405  return $filePath;
1406  }
1407 
1414  public function ‪getFile(‪$identifier)
1415  {
1416  $file = $this->‪getFileByIdentifier(‪$identifier);
1417  if (!$this->driver->fileExists(‪$identifier)) {
1418  $file->setMissing(true);
1419  }
1420  return $file;
1421  }
1422 
1430  public function ‪getFileByIdentifier(string $fileIdentifier)
1431  {
1432  if (!$this->‪isWithinProcessingFolder($fileIdentifier)) {
1433  $fileData = $this->‪getFileIndexRepository()->‪findOneByStorageAndIdentifier(‪$this, $fileIdentifier);
1434  if ($fileData === false) {
1435  return $this->‪getIndexer()->‪createIndexEntry($fileIdentifier);
1436  }
1437  return $this->‪getResourceFactoryInstance()->getFileObject($fileData['uid'], $fileData);
1438  }
1439  return $this->‪getProcessedFileRepository()->findByStorageAndIdentifier(‪$this, $fileIdentifier);
1440  }
1441 
1443  {
1444  return GeneralUtility::makeInstance(ProcessedFileRepository::class);
1445  }
1446 
1453  public function ‪getFileInfo(FileInterface $fileObject)
1454  {
1455  return $this->‪getFileInfoByIdentifier($fileObject->getIdentifier());
1456  }
1457 
1465  public function ‪getFileInfoByIdentifier(‪$identifier, array $propertiesToExtract = [])
1466  {
1467  return $this->driver->getFileInfoByIdentifier(‪$identifier, $propertiesToExtract);
1468  }
1469 
1473  public function ‪unsetFileAndFolderNameFilters()
1474  {
1475  $this->‪fileAndFolderNameFilters = [];
1476  }
1477 
1482  {
1483  $this->‪fileAndFolderNameFilters = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['defaultFilterCallbacks'];
1484  }
1485 
1492  public function getImportExportFilter(): array
1493  {
1494  $filter = GeneralUtility::makeInstance(ImportExportFilter::class);
1495 
1496  return [$filter, 'filterImportExportFilesAndFolders'];
1497  }
1498 
1504  public function ‪getFileAndFolderNameFilters()
1505  {
1506  return array_merge($this->‪fileAndFolderNameFilters, [$this->getImportExportFilter()]);
1507  }
1512  public function setFileAndFolderNameFilters(array $filters)
1513  {
1514  $this->‪fileAndFolderNameFilters = $filters;
1515  return ‪$this;
1516  }
1517 
1521  public function ‪addFileAndFolderNameFilter($filter)
1522  {
1523  $this->‪fileAndFolderNameFilters[] = $filter;
1524  }
1525 
1531  public function ‪getFolderIdentifierFromFileIdentifier($fileIdentifier)
1532  {
1533  return $this->driver->getParentFolderIdentifierOfIdentifier($fileIdentifier);
1534  }
1535 
1542  public function ‪getFileInFolder($fileName, Folder $folder)
1543  {
1544  ‪$identifier = $this->driver->getFileInFolder($fileName, $folder->getIdentifier());
1545  return $this->‪getFileByIdentifier(‪$identifier);
1546  }
1547 
1562  public function ‪getFilesInFolder(Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
1563  {
1564  $this->‪assureFolderReadPermission($folder);
1565 
1566  $rows = $this->‪getFileIndexRepository()->‪findByFolder($folder);
1567 
1568  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
1569  $fileIdentifiers = array_values($this->driver->getFilesInFolder($folder->getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev));
1570 
1571  $items = [];
1572  foreach ($fileIdentifiers as ‪$identifier) {
1573  if (isset($rows[‪$identifier])) {
1574  $fileObject = $this->‪getFileFactory()->‪getFileObject($rows[‪$identifier]['uid'], $rows[‪$identifier]);
1575  } else {
1576  $fileObject = $this->‪getFileByIdentifier($identifier);
1577  }
1578  if ($fileObject instanceof FileInterface) {
1579  $key = $fileObject->‪getName();
1580  while (isset($items[$key])) {
1581  $key .= 'z';
1582  }
1583  $items[$key] = $fileObject;
1584  }
1585  }
1586 
1587  return $items;
1588  }
1589 
1596  public function ‪getFileIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
1597  {
1598  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
1599  return $this->driver->getFilesInFolder($folderIdentifier, 0, 0, $recursive, $filters);
1600  }
1601 
1608  public function ‪countFilesInFolder(‪Folder $folder, $useFilters = true, $recursive = false)
1609  {
1610  $this->‪assureFolderReadPermission($folder);
1611  $filters = $useFilters ? $this->‪getFileAndFolderNameFilters() : [];
1612  return $this->driver->countFilesInFolder($folder->‪getIdentifier(), $recursive, $filters);
1613  }
1614 
1621  public function ‪getFolderIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
1622  {
1623  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
1624  return $this->driver->getFoldersInFolder($folderIdentifier, 0, 0, $recursive, $filters);
1625  }
1626 
1633  public function ‪hasFile(‪$identifier)
1634  {
1635  // Allow if identifier is in processing folder
1636  if (!$this->‪isWithinProcessingFolder($identifier)) {
1638  }
1639  return $this->driver->fileExists(‪$identifier);
1640  }
1641 
1647  public function ‪getProcessingFolders()
1648  {
1649  if ($this->processingFolders === null) {
1650  $this->processingFolders = [];
1651  $this->processingFolders[] = $this->‪getProcessingFolder();
1652  $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
1653  $allStorages = $storageRepository->findAll();
1654  foreach ($allStorages as $storage) {
1655  // To circumvent the permission check of the folder, we use the factory to create it "manually" instead of directly using $storage->getProcessingFolder()
1656  // See #66695 for details
1657  [$storageUid, $processingFolderIdentifier] = array_pad(GeneralUtility::trimExplode(':', $storage->getStorageRecord()['processingfolder'] ?? ''), 2, null);
1658  if (empty($processingFolderIdentifier) || (int)$storageUid !== $this->‪getUid()) {
1659  continue;
1660  }
1661  $potentialProcessingFolder = $this->‪createFolderObject($processingFolderIdentifier, $processingFolderIdentifier);
1662  if ($potentialProcessingFolder->getStorage() === ‪$this && $potentialProcessingFolder->getIdentifier() !== ‪$this->getProcessingFolder()->getIdentifier()) {
1663  $this->processingFolders[] = $potentialProcessingFolder;
1664  }
1665  }
1666  }
1667 
1669  }
1670 
1677  public function ‪isProcessingFolder(Folder $folder)
1678  {
1679  $isProcessingFolder = false;
1680  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
1681  if ($folder->getCombinedIdentifier() === ‪$processingFolder->‪getCombinedIdentifier()) {
1682  $isProcessingFolder = true;
1683  break;
1684  }
1685  }
1686  return $isProcessingFolder;
1687  }
1688 
1695  public function ‪hasFileInFolder($fileName, Folder $folder)
1696  {
1697  $this->‪assureFolderReadPermission($folder);
1698  return $this->driver->fileExistsInFolder($fileName, $folder->getIdentifier());
1699  }
1700 
1709  public function ‪getFileContents($file)
1710  {
1711  $this->‪assureFileReadPermission($file);
1712  return $this->driver->getFileContents($file->getIdentifier());
1713  }
1714 
1722  public function ‪streamFile(
1723  ‪FileInterface $file,
1724  bool $asDownload = false,
1725  string $alternativeFilename = null,
1726  string $overrideMimeType = null
1727  ): ResponseInterface {
1728  if (!$this->driver instanceof ‪StreamableDriverInterface) {
1729  return $this->‪getPseudoStream($file, $asDownload, $alternativeFilename, $overrideMimeType);
1730  }
1731 
1732  $properties = [
1733  'as_download' => $asDownload,
1734  'filename_overwrite' => $alternativeFilename,
1735  'mimetype_overwrite' => $overrideMimeType,
1736  ];
1737  return $this->driver->streamFile($file->‪getIdentifier(), $properties);
1738  }
1739 
1748  protected function ‪getPseudoStream(
1749  ‪FileInterface $file,
1750  bool $asDownload = false,
1751  string $alternativeFilename = null,
1752  string $overrideMimeType = null
1753  ) {
1754  $downloadName = $alternativeFilename ?: $file->‪getName();
1755  $contentDisposition = $asDownload ? 'attachment' : 'inline';
1756 
1757  $stream = new ‪FalDumpFileContentsDecoratorStream($file->‪getIdentifier(), ‪$this->driver, $file->getSize());
1758  $fileInfo = $this->driver->getFileInfoByIdentifier($file->‪getIdentifier(), ['mtime']);
1759  $headers = [
1760  'Content-Disposition' => $contentDisposition . '; filename="' . $downloadName . '"',
1761  'Content-Type' => $overrideMimeType ?: $file->getMimeType(),
1762  'Content-Length' => (string)$file->getSize(),
1763  'Last-Modified' => gmdate('D, d M Y H:i:s', array_pop($fileInfo)) . ' GMT',
1764  // Cache-Control header is needed here to solve an issue with browser IE8 and lower
1765  // See for more information: http://support.microsoft.com/kb/323308
1766  'Cache-Control' => '',
1767  ];
1768 
1769  return new ‪Response($stream, 200, $headers);
1770  }
1771 
1782  public function ‪setFileContents(‪AbstractFile $file, $contents)
1783  {
1784  // Check if user is allowed to edit
1785  $this->‪assureFileWritePermissions($file);
1786  $this->eventDispatcher->dispatch(
1787  new ‪BeforeFileContentsSetEvent($file, $contents)
1788  );
1789  // Call driver method to update the file and update file index entry afterwards
1790  $result = $this->driver->setFileContents($file->‪getIdentifier(), $contents);
1791  if ($file instanceof ‪File) {
1792  $this->‪getIndexer()->‪updateIndexEntry($file);
1793  }
1794  $this->eventDispatcher->dispatch(
1795  new AfterFileContentsSetEvent($file, $contents)
1796  );
1797  return $result;
1798  }
1812  public function ‪createFile($fileName, ‪Folder $targetFolderObject)
1813  {
1814  $this->‪assureFileAddPermissions($targetFolderObject, $fileName);
1815  $this->eventDispatcher->dispatch(
1816  new ‪BeforeFileCreatedEvent($fileName, $targetFolderObject)
1817  );
1818  $newFileIdentifier = $this->driver->createFile($fileName, $targetFolderObject->‪getIdentifier());
1819  $this->eventDispatcher->dispatch(
1820  new ‪AfterFileCreatedEvent($newFileIdentifier, $targetFolderObject)
1821  );
1822  return $this->‪getFileByIdentifier($newFileIdentifier);
1823  }
1824 
1833  public function ‪deleteFile($fileObject)
1834  {
1835  $this->‪assureFileDeletePermissions($fileObject);
1836 
1837  $this->eventDispatcher->dispatch(
1838  new ‪BeforeFileDeletedEvent($fileObject)
1839  );
1840  $deleted = true;
1841 
1842  if ($this->driver->fileExists($fileObject->‪getIdentifier())) {
1843  // Disable permission check to find nearest recycler and move file without errors
1844  $currentPermissions = ‪$this->evaluatePermissions;
1845  $this->evaluatePermissions = false;
1846 
1847  $recyclerFolder = $this->‪getNearestRecyclerFolder($fileObject);
1848  if ($recyclerFolder === null) {
1849  $result = $this->driver->deleteFile($fileObject->‪getIdentifier());
1850  } else {
1851  $result = $this->‪moveFile($fileObject, $recyclerFolder);
1852  $deleted = false;
1853  }
1854 
1855  $this->evaluatePermissions = $currentPermissions;
1856 
1857  if (!$result) {
1858  throw new FileOperationErrorException('Deleting the file "' . $fileObject->‪getIdentifier() . '\' failed.', 1329831691);
1859  }
1860  }
1861  // Mark the file object as deleted
1862  if ($deleted && $fileObject instanceof AbstractFile) {
1863  $fileObject->setDeleted();
1864  }
1865 
1866  $this->eventDispatcher->dispatch(
1867  new AfterFileDeletedEvent($fileObject)
1868  );
1869 
1870  return true;
1871  }
1885  public function copyFile(FileInterface $file, Folder $targetFolder, $targetFileName = null, $conflictMode = DuplicationBehavior::RENAME)
1886  {
1887  $conflictMode = DuplicationBehavior::cast($conflictMode);
1888  if ($targetFileName === null) {
1889  $targetFileName = $file->getName();
1890  }
1891  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
1892  $this->assureFileCopyPermissions($file, $targetFolder, $sanitizedTargetFileName);
1893 
1894  $this->eventDispatcher->dispatch(
1895  new BeforeFileCopiedEvent($file, $targetFolder)
1896  );
1897 
1898  // File exists and we should abort, let's abort
1899  ‪if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && $targetFolder->hasFile($sanitizedTargetFileName)) {
1900  throw new ExistingTargetFileNameException('The target file already exists.', 1320291064);
1901  }
1902  // File exists and we should find another name, let's find another one
1903  ‪if ($conflictMode->equals(‪DuplicationBehavior::RENAME) && $targetFolder->hasFile($sanitizedTargetFileName)) {
1904  $sanitizedTargetFileName = $this->getUniqueName($targetFolder, $sanitizedTargetFileName);
1905  }
1906  $sourceStorage = $file->‪getStorage();
1907  // Call driver method to create a new file from an existing file object,
1908  // and return the new file object
1909  ‪if ($sourceStorage === ‪$this) {
1910  $newFileObjectIdentifier = $this->driver->copyFileWithinStorage($file->‪getIdentifier(), $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1911  } else {
1912  $tempPath = $file->‪getForLocalProcessing();
1913  $newFileObjectIdentifier = $this->driver->addFile($tempPath, $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1914  }
1915  $newFileObject = $this->‪getFileByIdentifier($newFileObjectIdentifier);
1916 
1917  // In case we deal with a file, also copy corresponding metadata
1918  if ($file instanceof File && $newFileObject !== null) {
1919  $metaDataAspect = $newFileObject->getMetaData();
1920  // Add meta data of file while keeping existing properties like "file", "uid", etc.
1921  $metaDataAspect->add(array_replace($file->getMetaData()->get(), $metaDataAspect->get()));
1922  $metaDataAspect->save();
1923  }
1924 
1925  $this->eventDispatcher->dispatch(
1926  new AfterFileCopiedEvent($file, $targetFolder, $newFileObjectIdentifier, $newFileObject)
1927  );
1928  return $newFileObject;
1929  }
1930 
1946  public function ‪moveFile($file, $targetFolder, $targetFileName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
1947  {
1948  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
1949  if ($targetFileName === null) {
1950  $targetFileName = $file->‪getName();
1951  }
1952  $originalFolder = $file->‪getParentFolder();
1953  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
1954  $this->‪assureFileMovePermissions($file, $targetFolder, $sanitizedTargetFileName);
1955  if ($targetFolder->hasFile($sanitizedTargetFileName)) {
1956  // File exists and we should abort, let's abort
1957  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
1958  $sanitizedTargetFileName = $this->‪getUniqueName($targetFolder, $sanitizedTargetFileName);
1959  } elseif ($conflictMode->equals(‪DuplicationBehavior::CANCEL)) {
1960  throw new ExistingTargetFileNameException('The target file already exists', 1329850997);
1961  }
1962  }
1963  $this->eventDispatcher->dispatch(
1964  new BeforeFileMovedEvent($file, $targetFolder, $sanitizedTargetFileName)
1965  );
1966  $sourceStorage = $file->‪getStorage();
1967  // Call driver method to move the file and update the index entry
1968  try {
1969  if ($sourceStorage === ‪$this) {
1970  $newIdentifier = $this->driver->moveFileWithinStorage($file->‪getIdentifier(), $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1971  if (!$file instanceof AbstractFile) {
1972  throw new \RuntimeException('The given file is not of type AbstractFile.', 1384209025);
1973  }
1974  $file->‪updateProperties(['identifier' => $newIdentifier]);
1975  } else {
1976  $tempPath = $file->‪getForLocalProcessing();
1977  $newIdentifier = $this->driver->addFile($tempPath, $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1978 
1979  // Disable permission check to find nearest recycler and move file without errors
1980  $currentPermissions = $sourceStorage->evaluatePermissions;
1981  $sourceStorage->evaluatePermissions = false;
1982 
1983  $recyclerFolder = $sourceStorage->getNearestRecyclerFolder($file);
1984  if ($recyclerFolder === null) {
1985  $sourceStorage->driver->deleteFile($file->‪getIdentifier());
1986  } else {
1987  $sourceStorage->moveFile($file, $recyclerFolder);
1988  }
1989  $sourceStorage->evaluatePermissions = $currentPermissions;
1990  if ($file instanceof File) {
1991  $file->‪updateProperties(['storage' => $this->‪getUid(), 'identifier' => $newIdentifier]);
1992  }
1993  }
1994  if ($file instanceof File) {
1995  $this->‪getIndexer()->‪updateIndexEntry($file);
1996  }
1997  } catch (\‪TYPO3\CMS\Core\Exception $e) {
1998  echo $e->getMessage();
1999  }
2000  $this->eventDispatcher->dispatch(
2001  new AfterFileMovedEvent($file, $targetFolder, $originalFolder)
2002  );
2003  return $file;
2004  }
2005 
2015  public function ‪renameFile($file, $targetFileName, $conflictMode = ‪DuplicationBehavior::RENAME)
2016  {
2017  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
2018  // The new name should be different from the current.
2019  if ($file->‪getName() === $sanitizedTargetFileName) {
2020  return $file;
2021  }
2022  $this->‪assureFileRenamePermissions($file, $sanitizedTargetFileName);
2023  $this->eventDispatcher->dispatch(
2024  new BeforeFileRenamedEvent($file, $sanitizedTargetFileName)
2025  );
2026 
2027  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2028 
2029  // Call driver method to rename the file and update the index entry
2030  try {
2031  $newIdentifier = $this->driver->renameFile($file->‪getIdentifier(), $sanitizedTargetFileName);
2032  if ($file instanceof File) {
2033  $file->‪updateProperties(['identifier' => $newIdentifier]);
2034  $this->‪getIndexer()->‪updateIndexEntry($file);
2035  }
2036  } catch (ExistingTargetFileNameException $exception) {
2037  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
2038  $newName = $this->‪getUniqueName($file->‪getParentFolder(), $sanitizedTargetFileName);
2039  $file = $this->‪renameFile($file, $newName);
2040  } elseif ($conflictMode->equals(‪DuplicationBehavior::CANCEL)) {
2041  throw $exception;
2042  } elseif ($conflictMode->equals(‪DuplicationBehavior::REPLACE)) {
2043  $sourceFileIdentifier = substr($file->‪getCombinedIdentifier(), 0, (int)strrpos($file->‪getCombinedIdentifier(), '/') + 1) . $sanitizedTargetFileName;
2044  $sourceFile = $this->‪getResourceFactoryInstance()->getFileObjectFromCombinedIdentifier($sourceFileIdentifier);
2045  $file = $this->‪replaceFile($sourceFile, ‪Environment::getPublicPath() . '/' . $file->‪getPublicUrl());
2046  }
2047  } catch (\RuntimeException $e) {
2048  }
2049 
2050  $this->eventDispatcher->dispatch(
2051  new AfterFileRenamedEvent($file, $sanitizedTargetFileName)
2052  );
2053 
2054  return $file;
2055  }
2056 
2067  public function ‪replaceFile(‪FileInterface $file, $localFilePath)
2068  {
2069  $this->‪assureFileReplacePermissions($file);
2070  if (!file_exists($localFilePath)) {
2071  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1325842622);
2072  }
2073  $this->eventDispatcher->dispatch(
2074  new BeforeFileReplacedEvent($file, $localFilePath)
2075  );
2076  $this->driver->replaceFile($file->‪getIdentifier(), $localFilePath);
2077  if ($file instanceof File) {
2078  $this->‪getIndexer()->‪updateIndexEntry($file);
2079  }
2080  $this->eventDispatcher->dispatch(
2081  new AfterFileReplacedEvent($file, $localFilePath)
2082  );
2083  return $file;
2084  }
2085 
2095  public function ‪addUploadedFile(array|‪UploadedFile $uploadedFileData, ‪Folder $targetFolder = null, $targetFileName = null, $conflictMode = ‪DuplicationBehavior::CANCEL)
2096  {
2097  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2098  if ($uploadedFileData instanceof ‪UploadedFile) {
2099  $localFilePath = $uploadedFileData->‪getTemporaryFileName();
2100  if ($targetFileName === null) {
2101  $targetFileName = $uploadedFileData->‪getClientFilename();
2102  }
2103  $size = $uploadedFileData->‪getSize();
2104  } else {
2105  $localFilePath = $uploadedFileData['tmp_name'];
2106  if ($targetFileName === null) {
2107  $targetFileName = \Normalizer::normalize($uploadedFileData['name']);
2108  }
2109  $size = $uploadedFileData['size'];
2110  }
2111  if ($targetFolder === null) {
2112  $targetFolder = $this->‪getDefaultFolder();
2113  }
2114 
2115  $targetFileName = $this->driver->sanitizeFileName($targetFileName);
2116 
2117  $this->‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $size);
2118  if ($this->‪hasFileInFolder($targetFileName, $targetFolder) && $conflictMode->equals(‪DuplicationBehavior::REPLACE)) {
2119  $file = $this->‪getFileInFolder($targetFileName, $targetFolder);
2120  $resultObject = $this->‪replaceFile($file, $localFilePath);
2121  } else {
2122  $resultObject = $this->‪addFile($localFilePath, $targetFolder, $targetFileName, (string)$conflictMode);
2123  }
2124  return $resultObject;
2125  }
2126 
2127  /********************
2128  * FOLDER ACTIONS
2129  ********************/
2135  protected function ‪getAllFileObjectsInFolder(Folder $folder)
2136  {
2137  $files = [];
2138  $folderQueue = [$folder];
2139  while (!empty($folderQueue)) {
2140  $folder = array_shift($folderQueue);
2141  foreach ($folder->getSubfolders() as $subfolder) {
2142  $folderQueue[] = $subfolder;
2143  }
2144  foreach ($folder->getFiles() as $file) {
2146  $files[$file->getIdentifier()] = $file;
2147  }
2148  }
2149 
2150  return $files;
2151  }
2152 
2167  public function ‪moveFolder(Folder $folderToMove, Folder $targetParentFolder, $newFolderName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2168  {
2169  // @todo add tests
2170  $this->‪assureFolderMovePermissions($folderToMove, $targetParentFolder);
2171  $sourceStorage = $folderToMove->getStorage();
2172  $sanitizedNewFolderName = $this->driver->sanitizeFileName($newFolderName ?: $folderToMove->getName());
2173  // @todo check if folder already exists in $targetParentFolder, handle this conflict then
2174  $this->eventDispatcher->dispatch(
2175  new BeforeFolderMovedEvent($folderToMove, $targetParentFolder, $sanitizedNewFolderName)
2176  );
2177  // Get all file objects now so we are able to update them after moving the folder
2178  $fileObjects = $this->‪getAllFileObjectsInFolder($folderToMove);
2179  if ($sourceStorage === ‪$this) {
2180  if ($this->‪isWithinFolder($folderToMove, $targetParentFolder)) {
2181  throw new InvalidTargetFolderException(
2182  sprintf(
2183  'Cannot move folder "%s" into target folder "%s", because the target folder is already within the folder to be moved!',
2184  $folderToMove->getName(),
2185  $targetParentFolder->getName()
2186  ),
2187  1422723050
2188  );
2189  }
2190  $fileMappings = $this->driver->moveFolderWithinStorage($folderToMove->getIdentifier(), $targetParentFolder->getIdentifier(), $sanitizedNewFolderName);
2191  } else {
2192  $fileMappings = $this->‪moveFolderBetweenStorages($folderToMove, $targetParentFolder, $sanitizedNewFolderName);
2193  }
2194  // Update the identifier and storage of all file objects
2195  foreach ($fileObjects as $oldIdentifier => $fileObject) {
2196  $newIdentifier = $fileMappings[$oldIdentifier];
2197  $fileObject->updateProperties(['storage' => $this->‪getUid(), 'identifier' => $newIdentifier]);
2198  $this->‪getIndexer()->‪updateIndexEntry($fileObject);
2199  }
2200  $returnObject = $this->‪getFolder($fileMappings[$folderToMove->getIdentifier()]);
2202  $this->eventDispatcher->dispatch(
2203  new ‪AfterFolderMovedEvent($folderToMove, $targetParentFolder, $returnObject)
2204  );
2205  return $returnObject;
2206  }
2207 
2214  protected function ‪moveFolderBetweenStorages(‪Folder $folderToMove, ‪Folder $targetParentFolder, $newFolderName)
2215  {
2216  throw new ‪NotImplementedMethodException('Not yet implemented', 1476046361);
2217  }
2218 
2229  public function ‪copyFolder(‪FolderInterface $folderToCopy, ‪FolderInterface $targetParentFolder, $newFolderName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2230  {
2231  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2232  $this->‪assureFolderCopyPermissions($folderToCopy, $targetParentFolder);
2233  $returnObject = null;
2234  $sanitizedNewFolderName = $this->driver->sanitizeFileName($newFolderName ?: $folderToCopy->‪getName());
2235  if ($folderToCopy instanceof ‪Folder && $targetParentFolder instanceof ‪Folder) {
2236  $this->eventDispatcher->dispatch(
2237  new ‪BeforeFolderCopiedEvent($folderToCopy, $targetParentFolder, $sanitizedNewFolderName)
2238  );
2239  }
2240  if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && ($targetParentFolder->‪hasFolder($sanitizedNewFolderName) || $targetParentFolder->‪hasFile($sanitizedNewFolderName))) {
2241  throw new InvalidTargetFolderException(
2242  sprintf(
2243  'Cannot copy folder "%s" into target folder "%s", because there is already a folder or file with that name in the target folder!',
2244  $sanitizedNewFolderName,
2245  $targetParentFolder->‪getIdentifier()
2246  ),
2247  1422723059
2248  );
2249  }
2250  // Folder exists and we should find another name, let's find another one
2251  if ($conflictMode->equals(‪DuplicationBehavior::RENAME) && ($targetParentFolder->‪hasFolder($sanitizedNewFolderName) || $targetParentFolder->‪hasFile($sanitizedNewFolderName))) {
2252  $sanitizedNewFolderName = $this->‪getUniqueName($targetParentFolder, $sanitizedNewFolderName);
2253  }
2254  $sourceStorage = $folderToCopy->‪getStorage();
2255  // call driver method to move the file
2256  // that also updates the file object properties
2257  if ($sourceStorage === ‪$this) {
2258  $this->driver->copyFolderWithinStorage($folderToCopy->‪getIdentifier(), $targetParentFolder->‪getIdentifier(), $sanitizedNewFolderName);
2259  $returnObject = $this->‪getFolder($targetParentFolder->‪getSubfolder($sanitizedNewFolderName)->getIdentifier());
2260  } else {
2261  $this->‪copyFolderBetweenStorages($folderToCopy, $targetParentFolder, $sanitizedNewFolderName);
2262  }
2263  if ($folderToCopy instanceof Folder && $targetParentFolder instanceof Folder) {
2264  $this->eventDispatcher->dispatch(
2265  new ‪AfterFolderCopiedEvent($folderToCopy, $targetParentFolder, $returnObject)
2266  );
2267  }
2268  return $returnObject;
2269  }
2270 
2277  protected function ‪copyFolderBetweenStorages(FolderInterface $folderToCopy, FolderInterface $targetParentFolder, $newFolderName)
2278  {
2279  throw new ‪NotImplementedMethodException('Not yet implemented.', 1476046386);
2280  }
2281 
2291  public function ‪renameFolder($folderObject, $newName)
2292  {
2293  // Renaming the folder should check if the parent folder is writable
2294  // We cannot do this however because we cannot extract the parent folder from a folder currently
2295  if (!$this->‪checkFolderActionPermission('rename', $folderObject)) {
2296  throw new ‪InsufficientUserPermissionsException('You are not allowed to rename the folder "' . $folderObject->getIdentifier() . '\'', 1357811441);
2297  }
2298 
2299  $sanitizedNewName = $this->driver->sanitizeFileName($newName);
2300  if ($this->driver->folderExistsInFolder($sanitizedNewName, $folderObject->getIdentifier())) {
2301  throw new \InvalidArgumentException('The folder ' . $sanitizedNewName . ' already exists in folder ' . $folderObject->getIdentifier(), 1325418870);
2302  }
2303  $this->eventDispatcher->dispatch(
2304  new BeforeFolderRenamedEvent($folderObject, $sanitizedNewName)
2305  );
2306  $fileObjects = $this->‪getAllFileObjectsInFolder($folderObject);
2307  $fileMappings = $this->driver->renameFolder($folderObject->getIdentifier(), $sanitizedNewName);
2308  // Update the identifier of all file objects
2309  foreach ($fileObjects as $oldIdentifier => $fileObject) {
2310  $newIdentifier = $fileMappings[$oldIdentifier];
2311  $fileObject->updateProperties(['identifier' => $newIdentifier]);
2312  $this->‪getIndexer()->‪updateIndexEntry($fileObject);
2313  }
2314  $returnObject = $this->‪getFolder($fileMappings[$folderObject->getIdentifier()]);
2315 
2316  $this->eventDispatcher->dispatch(
2317  new AfterFolderRenamedEvent($returnObject, $folderObject)
2318  );
2319  return $returnObject;
2320  }
2334  public function ‪deleteFolder($folderObject, $deleteRecursively = false)
2335  {
2336  $isEmpty = $this->driver->isFolderEmpty($folderObject->getIdentifier());
2337  $this->‪assureFolderDeletePermission($folderObject, $deleteRecursively && !$isEmpty);
2338  if (!$isEmpty && !$deleteRecursively) {
2339  throw new \RuntimeException('Could not delete folder "' . $folderObject->getIdentifier() . '" because it is not empty.', 1325952534);
2340  }
2341 
2342  $this->eventDispatcher->dispatch(
2343  new ‪BeforeFolderDeletedEvent($folderObject)
2344  );
2345 
2346  foreach ($this->‪getFilesInFolder($folderObject, 0, 0, false, $deleteRecursively) as $file) {
2347  $this->‪deleteFile($file);
2348  }
2349 
2350  $result = $this->driver->deleteFolder($folderObject->getIdentifier(), $deleteRecursively);
2351 
2352  $this->eventDispatcher->dispatch(
2353  new ‪AfterFolderDeletedEvent($folderObject, $result)
2354  );
2355  return $result;
2356  }
2357 
2367  public function ‪getFolderInFolder($folderName, ‪Folder $parentFolder, $returnInaccessibleFolderObject = false)
2368  {
2369  $folderIdentifier = $this->driver->getFolderInFolder($folderName, $parentFolder->‪getIdentifier());
2370  return $this->‪getFolder($folderIdentifier, $returnInaccessibleFolderObject);
2371  }
2372 
2386  public function getFoldersInFolder(Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
2387  {
2388  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
2389 
2390  ‪$folderIdentifiers = $this->driver->getFoldersInFolder($folder->getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev);
2391 
2392  // Exclude processing folders
2393  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
2394  $processingIdentifier = ‪$processingFolder->‪getIdentifier();
2395  if (isset(‪$folderIdentifiers[$processingIdentifier])) {
2396  unset(‪$folderIdentifiers[$processingIdentifier]);
2397  }
2398  }
2399 
2400  ‪$folders = [];
2401  foreach (‪$folderIdentifiers as $folderIdentifier) {
2402  // The folder identifier can also be an int-like string, resulting in int array keys.
2403  ‪$folders[$folderIdentifier] = $this->‪getFolder($folderIdentifier, true);
2404  }
2405  return ‪$folders;
2406  }
2407 
2414  public function ‪countFoldersInFolder(‪Folder $folder, $useFilters = true, $recursive = false)
2415  {
2416  $this->‪assureFolderReadPermission($folder);
2417  $filters = $useFilters ? $this->‪getFileAndFolderNameFilters() : [];
2418  return $this->driver->countFoldersInFolder($folder->‪getIdentifier(), $recursive, $filters);
2419  }
2420 
2427  public function ‪hasFolder(‪$identifier)
2428  {
2430  return $this->driver->folderExists(‪$identifier);
2431  }
2432 
2439  public function ‪hasFolderInFolder($folderName, Folder $folder)
2440  {
2441  $this->‪assureFolderReadPermission($folder);
2442  return $this->driver->folderExistsInFolder($folderName, $folder->getIdentifier());
2443  }
2444 
2458  public function ‪createFolder($folderName, Folder $parentFolder = null)
2459  {
2460  if ($parentFolder === null) {
2461  $parentFolder = $this->‪getRootLevelFolder();
2462  } elseif (!$this->driver->folderExists($parentFolder->getIdentifier())) {
2463  throw new \InvalidArgumentException('Parent folder "' . $parentFolder->getIdentifier() . '" does not exist.', 1325689164);
2464  }
2465  if (!$this->‪checkFolderActionPermission('add', $parentFolder)) {
2466  throw new InsufficientFolderWritePermissionsException('You are not allowed to create directories in the folder "' . $parentFolder->getIdentifier() . '"', 1323059807);
2467  }
2468  if ($this->driver->folderExistsInFolder($folderName, $parentFolder->getIdentifier())) {
2469  throw new ExistingTargetFolderException('Folder "' . $folderName . '" already exists.', 1423347324);
2470  }
2471 
2472  $this->eventDispatcher->dispatch(
2473  new BeforeFolderAddedEvent($parentFolder, $folderName)
2474  );
2475 
2476  $newFolder = $this->‪getDriver()->createFolder($folderName, $parentFolder->getIdentifier(), true);
2477  $newFolder = $this->‪getFolder($newFolder);
2479  $this->eventDispatcher->dispatch(
2480  new ‪AfterFolderAddedEvent($newFolder)
2481  );
2482 
2483  return $newFolder;
2484  }
2485 
2491  public function ‪getFolderInfo(‪Folder $folder)
2492  {
2493  return $this->driver->getFolderInfoByIdentifier($folder->‪getIdentifier());
2494  }
2495 
2501  public function ‪getDefaultFolder()
2502  {
2503  return $this->‪getFolder($this->driver->getDefaultFolder());
2504  }
2505 
2514  public function ‪getFolder(‪$identifier, $returnInaccessibleFolderObject = false)
2515  {
2516  $data = $this->driver->getFolderInfoByIdentifier(‪$identifier);
2517  $folder = $this->‪createFolderObject($data['identifier'], $data['name']);
2518 
2519  try {
2520  $this->‪assureFolderReadPermission($folder);
2521  } catch (InsufficientFolderAccessPermissionsException $e) {
2522  $folder = null;
2523  if ($returnInaccessibleFolderObject) {
2524  // if parent folder is readable return inaccessible folder object
2525  $parentPermissions = $this->driver->getPermissions($this->driver->getParentFolderIdentifierOfIdentifier(‪$identifier));
2526  if ($parentPermissions['r']) {
2527  $folder = GeneralUtility::makeInstance(
2528  InaccessibleFolder::class,
2529  ‪$this,
2530  $data['identifier'],
2531  $data['name']
2532  );
2533  }
2534  }
2535 
2536  if ($folder === null) {
2537  throw $e;
2538  }
2539  }
2540  return $folder;
2541  }
2542 
2550  {
2551  $inProcessingFolder = false;
2552  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
2554  $inProcessingFolder = true;
2555  break;
2556  }
2557  }
2558  return $inProcessingFolder;
2559  }
2560 
2567  public function ‪isWithinFolder(Folder $folder, ResourceInterface $resource)
2568  {
2569  if ($folder->getStorage() !== ‪$this) {
2570  throw new \InvalidArgumentException('Given folder "' . $folder->getIdentifier() . '" is not part of this storage!', 1422709241);
2571  }
2572  if ($folder->getStorage() !== $resource->getStorage()) {
2573  return false;
2574  }
2575  return $this->driver->isWithin($folder->getIdentifier(), $resource->getIdentifier());
2576  }
2577 
2587  public function ‪getRootLevelFolder($respectFileMounts = true)
2588  {
2589  if ($respectFileMounts && !empty($this->fileMounts)) {
2590  $mount = reset($this->fileMounts);
2591  return $mount['folder'];
2592  }
2593  return $this->‪createFolderObject($this->driver->getRootLevelFolder(), '');
2594  }
2595 
2610  protected function ‪getUniqueName(FolderInterface $folder, $theFile, $dontCheckForUnique = false)
2611  {
2612  $maxNumber = 99;
2613  // Fetches info about path, name, extension of $theFile
2614  $origFileInfo = ‪PathUtility::pathinfo($theFile);
2615  // Check if the file exists and if not - return the fileName...
2616  // The destinations file
2617  $theDestFile = $origFileInfo['basename'];
2618  // If the file does NOT exist we return this fileName
2619  if ($dontCheckForUnique || (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier()) && !‪$this->driver->folderExistsInFolder($theDestFile, $folder->getIdentifier()))) {
2620  return $theDestFile;
2621  }
2622  // Well the fileName in its pure form existed. Now we try to append
2623  // numbers / unique-strings and see if we can find an available fileName
2624  // This removes _xx if appended to the file
2625  $theTempFileBody = preg_replace('/_[0-9][0-9]$/', '', $origFileInfo['filename']);
2626  $theOrigExt = ($origFileInfo['extension'] ?? '') ? '.' . $origFileInfo['extension'] : '';
2627  for ($a = 1; $a <= $maxNumber + 1; $a++) {
2628  // First we try to append numbers
2629  if ($a <= $maxNumber) {
2630  $insert = '_' . sprintf('%02d', $a);
2631  } else {
2632  $insert = '_' . substr(md5(‪StringUtility::getUniqueId()), 0, 6);
2633  }
2634  $theTestFile = $theTempFileBody . $insert . $theOrigExt;
2635  // The destinations file
2636  $theDestFile = $theTestFile;
2637  // If the file does NOT exist we return this fileName
2638  if (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier()) && !‪$this->driver->folderExistsInFolder($theDestFile, $folder->getIdentifier())) {
2639  return $theDestFile;
2640  }
2641  }
2642  throw new \RuntimeException('Last possible name "' . $theDestFile . '" is already taken.', 1325194291);
2643  }
2644 
2648  protected function ‪getFileFactory()
2649  {
2650  return GeneralUtility::makeInstance(ResourceFactory::class);
2651  }
2652 
2656  protected function ‪getFileIndexRepository()
2657  {
2658  return GeneralUtility::makeInstance(FileIndexRepository::class);
2659  }
2660 
2664  protected function ‪getFileProcessingService()
2665  {
2666  if (!$this->fileProcessingService) {
2667  $this->fileProcessingService = GeneralUtility::makeInstance(FileProcessingService::class);
2668  }
2670  }
2671 
2678  public function ‪getRole(‪FolderInterface $folder)
2679  {
2680  $folderRole = ‪FolderInterface::ROLE_DEFAULT;
2681  ‪$identifier = $folder->‪getIdentifier();
2682  if (method_exists($this->driver, 'getRole')) {
2683  $folderRole = $this->driver->getRole($folder->‪getIdentifier());
2684  }
2685  if (isset($this->fileMounts[‪$identifier])) {
2686  $folderRole = ‪FolderInterface::ROLE_MOUNT;
2687 
2688  if (!empty($this->fileMounts[‪$identifier]['read_only'])) {
2690  }
2691  if ($this->fileMounts[‪$identifier]['user_mount'] ?? false) {
2693  }
2694  }
2695  if ($folder instanceof Folder && $this->‪isProcessingFolder($folder)) {
2697  }
2698 
2699  return $folderRole;
2700  }
2701 
2709  public function ‪getProcessingFolder(File $file = null)
2710  {
2711  // If a file is given, make sure to return the processing folder of the correct storage
2712  if ($file !== null && $file->‪getStorage()->getUid() !== ‪$this->getUid()) {
2713  return $file->‪getStorage()->getProcessingFolder($file);
2714  }
2715  if (!isset($this->processingFolder)) {
2717  if (!empty($this->storageRecord['processingfolder'])) {
2718  ‪$processingFolder = $this->storageRecord['processingfolder'];
2719  }
2720  try {
2721  if (str_contains(‪$processingFolder, ':')) {
2722  [$storageUid, $processingFolderIdentifier] = explode(':', ‪$processingFolder, 2);
2723  $storage = GeneralUtility::makeInstance(StorageRepository::class)->findByUid((int)$storageUid);
2724  if ($storage->hasFolder($processingFolderIdentifier)) {
2725  $this->processingFolder = $storage->getFolder($processingFolderIdentifier);
2726  } else {
2727  $rootFolder = $storage->getRootLevelFolder(false);
2728  $currentEvaluatePermissions = $storage->getEvaluatePermissions();
2729  $storage->setEvaluatePermissions(false);
2730  $this->processingFolder = $storage->createFolder(
2731  ltrim($processingFolderIdentifier, '/'),
2732  $rootFolder
2733  );
2734  $storage->setEvaluatePermissions($currentEvaluatePermissions);
2735  }
2736  } else {
2737  if ($this->driver->folderExists(‪$processingFolder) === false) {
2738  $rootFolder = $this->‪getRootLevelFolder(false);
2739  try {
2740  $currentEvaluatePermissions = ‪$this->evaluatePermissions;
2741  $this->evaluatePermissions = false;
2742  $this->processingFolder = $this->‪createFolder(
2743  $processingFolder,
2744  $rootFolder
2745  );
2746  $this->evaluatePermissions = $currentEvaluatePermissions;
2747  } catch (\InvalidArgumentException $e) {
2748  $this->processingFolder = GeneralUtility::makeInstance(
2749  InaccessibleFolder::class,
2750  ‪$this,
2753  );
2754  }
2755  } else {
2756  $data = $this->driver->getFolderInfoByIdentifier(‪$processingFolder);
2757  $this->processingFolder = $this->‪createFolderObject($data['identifier'], $data['name']);
2758  }
2759  }
2760  } catch (InsufficientFolderWritePermissionsException|ResourcePermissionsUnavailableException $e) {
2761  $this->processingFolder = GeneralUtility::makeInstance(
2762  InaccessibleFolder::class,
2763  ‪$this,
2766  );
2767  }
2768  }
2769 
2771  if (!empty($file)) {
2773  }
2774  return ‪$processingFolder;
2775  }
2776 
2784  protected function ‪getNestedProcessingFolder(File $file, Folder $rootProcessingFolder)
2785  {
2786  ‪$processingFolder = $rootProcessingFolder;
2787  $nestedFolderNames = $this->‪getNamesForNestedProcessingFolder(
2788  $file->getIdentifier(),
2789  self::PROCESSING_FOLDER_LEVELS
2790  );
2791 
2792  try {
2793  foreach ($nestedFolderNames as $folderName) {
2794  if (‪$processingFolder->‪hasFolder($folderName)) {
2796  } else {
2797  $currentEvaluatePermissions = ‪$processingFolder->‪getStorage()->getEvaluatePermissions();
2798  ‪$processingFolder->‪getStorage()->setEvaluatePermissions(false);
2800  ‪$processingFolder->‪getStorage()->setEvaluatePermissions($currentEvaluatePermissions);
2801  }
2802  }
2804  }
2805 
2806  return ‪$processingFolder;
2807  }
2808 
2816  protected function ‪getNamesForNestedProcessingFolder($fileIdentifier, $levels)
2817  {
2818  $names = [];
2819  if ($levels === 0) {
2820  return $names;
2821  }
2822  $hash = md5($fileIdentifier);
2823  for ($i = 1; $i <= $levels; $i++) {
2824  $names[] = substr($hash, $i, 1);
2825  }
2826  return $names;
2827  }
2828 
2834  public function ‪getDriverType()
2835  {
2836  return $this->storageRecord['driver'];
2837  }
2838 
2844  protected function ‪getIndexer()
2845  {
2846  return GeneralUtility::makeInstance(Indexer::class, ‪$this);
2847  }
2848 
2852  public function ‪setDefault(‪$isDefault)
2853  {
2854  $this->‪isDefault = (bool)‪$isDefault;
2855  }
2856 
2860  public function ‪isDefault()
2861  {
2862  return ‪$this->isDefault;
2863  }
2864 
2866  {
2867  return GeneralUtility::makeInstance(ResourceFactory::class);
2868  }
2869 
2870  protected function ‪getBackendUser(): BackendUserAuthentication
2871  {
2872  return ‪$GLOBALS['BE_USER'];
2873  }
2874 
2886  protected function ‪getNearestRecyclerFolder(‪FileInterface $file)
2887  {
2888  if ($file instanceof ‪ProcessedFile) {
2889  return null;
2890  }
2891  // if the storage is not browsable we cannot fetch the parent folder of the file so no recycler handling is possible
2892  if (!$this->‪isBrowsable()) {
2893  return null;
2894  }
2895 
2896  $recyclerFolder = null;
2897  $folder = $file->‪getParentFolder();
2898 
2899  do {
2900  if ($folder->getRole() === ‪FolderInterface::ROLE_RECYCLER) {
2901  break;
2902  }
2903 
2904  foreach ($folder->‪getSubfolders() as $subFolder) {
2905  if ($subFolder->getRole() === ‪FolderInterface::ROLE_RECYCLER) {
2906  $recyclerFolder = $subFolder;
2907  break;
2908  }
2909  }
2910 
2911  $parentFolder = $folder->‪getParentFolder();
2912  $isFolderLoop = $folder->‪getIdentifier() === $parentFolder->getIdentifier();
2913  $folder = $parentFolder;
2914  } while ($recyclerFolder === null && !$isFolderLoop);
2915 
2916  return $recyclerFolder;
2917  }
2918 
2926  protected function ‪createFolderObject(string ‪$identifier, string $name)
2927  {
2928  return GeneralUtility::makeInstance(Folder::class, ‪$this, ‪$identifier, $name);
2929  }
2930 }
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderRenamedEvent
Definition: BeforeFolderRenamedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\processFile
‪processFile(File|FileReference $fileObject, string $context, array $configuration)
Definition: ResourceStorage.php:1375
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileProcessingService
‪Service FileProcessingService getFileProcessingService()
Definition: ResourceStorage.php:2651
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileAndFolderNameFilters
‪array $fileAndFolderNameFilters
Definition: ResourceStorage.php:205
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileByIdentifier
‪File ProcessedFile null getFileByIdentifier(string $fileIdentifier)
Definition: ResourceStorage.php:1417
‪TYPO3\CMS\Core\Resource\ResourceStorage\getBackendUser
‪getBackendUser()
Definition: ResourceStorage.php:2857
‪TYPO3\CMS\Core\Resource\Search\Result\EmptyFileSearchResult
Definition: EmptyFileSearchResult.php:24
‪TYPO3\CMS\Core\Utility\PathUtility\getCanonicalPath
‪static string getCanonicalPath(string $path)
Definition: PathUtility.php:364
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderDeletedEvent
Definition: BeforeFolderDeletedEvent.php:28
‪TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile
‪File getOriginalFile()
Definition: ProcessedFile.php:301
‪TYPO3\CMS\Core\Resource\ProcessedFileRepository
Definition: ProcessedFileRepository.php:37
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileWritePermissionsException
Definition: InsufficientFileWritePermissionsException.php:22
‪TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException
Definition: InsufficientUserPermissionsException.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\renameFolder
‪Folder renameFolder($folderObject, $newName)
Definition: ResourceStorage.php:2278
‪TYPO3\CMS\Core\Resource\Event\BeforeFileCopiedEvent
Definition: BeforeFileCopiedEvent.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\deleteFolder
‪bool deleteFolder($folderObject, $deleteRecursively=false)
Definition: ResourceStorage.php:2321
‪TYPO3\CMS\Core\Resource\ResourceInterface\getIdentifier
‪getIdentifier()
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository
Definition: FileIndexRepository.php:44
‪TYPO3\CMS\Core\Resource\Event\BeforeFileCreatedEvent
Definition: BeforeFileCreatedEvent.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileAndFolderNameFilter
‪addFileAndFolderNameFilter($filter)
Definition: ResourceStorage.php:1508
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:27
‪TYPO3\CMS\Core\Resource\Capabilities\CAPABILITY_PUBLIC
‪const CAPABILITY_PUBLIC
Definition: Capabilities.php:31
‪TYPO3\CMS\Core\Resource\ResourceStorage\resetFileAndFolderNameFiltersToDefault
‪resetFileAndFolderNameFiltersToDefault()
Definition: ResourceStorage.php:1468
‪TYPO3\CMS\Core\Resource\ResourceStorage\countFilesInFolder
‪int countFilesInFolder(Folder $folder, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1595
‪TYPO3\CMS\Core\Resource\FolderInterface\getSubfolder
‪getSubfolder(string $name)
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry
Definition: OnlineMediaHelperRegistry.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInfo
‪array getFileInfo(FileInterface $fileObject)
Definition: ResourceStorage.php:1440
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface
Definition: ResourceStorageInterface.php:22
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException
Definition: ExistingTargetFolderException.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\markAsTemporaryOffline
‪markAsTemporaryOffline()
Definition: ResourceStorage.php:522
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUid
‪int getUid()
Definition: ResourceStorage.php:336
‪TYPO3\CMS\Core\Resource\ResourceStorage\setUserPermissions
‪setUserPermissions(array $userPermissions)
Definition: ResourceStorage.php:657
‪TYPO3\CMS\Core\Resource\Event\BeforeFileReplacedEvent
Definition: BeforeFileReplacedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInfoByIdentifier
‪array getFileInfoByIdentifier($identifier, array $propertiesToExtract=[])
Definition: ResourceStorage.php:1452
‪TYPO3\CMS\Core\Resource\AbstractFile\getForLocalProcessing
‪non empty string getForLocalProcessing(bool $writable=true)
Definition: AbstractFile.php:551
‪TYPO3\CMS\Core\Resource\ResourceStorage\getEvaluatePermissions
‪bool getEvaluatePermissions()
Definition: ResourceStorage.php:649
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderInFolder
‪Folder InaccessibleFolder getFolderInFolder($folderName, Folder $parentFolder, $returnInaccessibleFolderObject=false)
Definition: ResourceStorage.php:2354
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\CANCEL
‪const CANCEL
Definition: DuplicationBehavior.php:46
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileReplacePermissions
‪assureFileReplacePermissions(FileInterface $file)
Definition: ResourceStorage.php:918
‪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:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDefaultFolder
‪Folder getDefaultFolder()
Definition: ResourceStorage.php:2488
‪TYPO3\CMS\Core\Resource\FileInterface
Definition: FileInterface.php:24
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
Definition: InsufficientFolderAccessPermissionsException.php:24
‪TYPO3\CMS\Core\Resource\ResourceInterface\getName
‪getName()
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFolder
‪Folder moveFolder(Folder $folderToMove, Folder $targetParentFolder, $newFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2154
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDriverType
‪string getDriverType()
Definition: ResourceStorage.php:2821
‪TYPO3\CMS\Core\Resource\ResourceStorage\searchFiles
‪searchFiles(FileSearchDemand $searchDemand, Folder $folder=null, bool $useFilters=true)
Definition: ResourceStorage.php:421
‪TYPO3\CMS\Core\Resource\FolderInterface\hasFolder
‪hasFolder(string $name)
‪TYPO3\CMS\Core\Resource\Security\FileNameValidator
Definition: FileNameValidator.php:25
‪TYPO3\CMS\Core\Resource\Capabilities
Definition: Capabilities.php:23
‪TYPO3\CMS\Core\Resource\AbstractFile\getParentFolder
‪getParentFolder()
Definition: AbstractFile.php:569
‪TYPO3\CMS\Core\Resource\ResourceStorage\$storageRecord
‪array $storageRecord
Definition: ResourceStorage.php:138
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_DEFAULT
‪const ROLE_DEFAULT
Definition: FolderInterface.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileExtensionPermission
‪bool checkFileExtensionPermission($fileName)
Definition: ResourceStorage.php:814
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFilesInFolder
‪File[] getFilesInFolder(Folder $folder, $start=0, $maxNumberOfItems=0, $useFilters=true, $recursive=false, $sort='', $sortRev=false)
Definition: ResourceStorage.php:1549
‪TYPO3\CMS\Core\Resource\ResourceStorage\getStorageRecord
‪array getStorageRecord()
Definition: ResourceStorage.php:295
‪TYPO3
‪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\getProcessingFolder
‪Folder getProcessingFolder(File $file=null)
Definition: ResourceStorage.php:2696
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileFactory
‪ResourceFactory getFileFactory()
Definition: ResourceStorage.php:2635
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileMount
‪addFileMount($folderIdentifier, $additionalData=[])
Definition: ResourceStorage.php:542
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static getPublicPath()
Definition: Environment.php:187
‪TYPO3\CMS\Core\Resource\ResourceStorage\getResourceFactoryInstance
‪getResourceFactoryInstance()
Definition: ResourceStorage.php:2852
‪TYPO3\CMS\Core\Registry
Definition: Registry.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\$configuration
‪array $configuration
Definition: ResourceStorage.php:144
‪TYPO3\CMS\Core\Resource\Folder\getSubfolders
‪getSubfolders($start=0, $numberOfItems=0, $filterMode=self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, $recursive=false)
Definition: Folder.php:266
‪TYPO3\CMS\Core\Resource\ResourceStorage\copyFolderBetweenStorages
‪copyFolderBetweenStorages(FolderInterface $folderToCopy, FolderInterface $targetParentFolder, $newFolderName)
Definition: ResourceStorage.php:2264
‪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:2501
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderIdentifierFromFileIdentifier
‪string getFolderIdentifierFromFileIdentifier($fileIdentifier)
Definition: ResourceStorage.php:1518
‪TYPO3\CMS\Core\Resource\ResourceStorage\replaceFile
‪FileInterface replaceFile(FileInterface $file, $localFilePath)
Definition: ResourceStorage.php:2054
‪TYPO3\CMS\Core\Resource\ResourceInterface\getStorage
‪getStorage()
‪TYPO3\CMS\Core\Resource\ResourceStorage\renameFile
‪FileInterface renameFile($file, $targetFileName, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2002
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFile
‪FileInterface getFile($identifier)
Definition: ResourceStorage.php:1401
‪TYPO3\CMS\Core\Resource\Event\BeforeFileRenamedEvent
Definition: BeforeFileRenamedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDriver
‪Driver DriverInterface getDriver()
Definition: ResourceStorage.php:316
‪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\FileReference
Definition: FileReference.php:35
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFileByIdentifier
‪string hashFileByIdentifier($fileIdentifier, $hash)
Definition: ResourceStorage.php:1297
‪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:1501
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
Definition: ExistingTargetFileNameException.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\DEFAULT_ProcessingFolder
‪const DEFAULT_ProcessingFolder
Definition: ResourceStorageInterface.php:26
‪TYPO3\CMS\Core\Resource\FolderInterface\getSubfolders
‪getSubfolders()
‪TYPO3\CMS\Core\Resource\AbstractFile\getName
‪getName()
Definition: AbstractFile.php:150
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessingFolders
‪Folder[] getProcessingFolders()
Definition: ResourceStorage.php:1634
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileIdentifiersInFolder
‪array getFileIdentifiersInFolder($folderIdentifier, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1583
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository\findByFolder
‪array null findByFolder(Folder $folder)
Definition: FileIndexRepository.php:174
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderInfo
‪array getFolderInfo(Folder $folder)
Definition: ResourceStorage.php:2478
‪TYPO3\CMS\Core\Resource\Index\Indexer\updateIndexEntry
‪updateIndexEntry(File $fileObject)
Definition: Indexer.php:92
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessedFileRepository
‪getProcessedFileRepository()
Definition: ResourceStorage.php:1429
‪TYPO3\CMS\Core\Resource\Event\BeforeFileMovedEvent
Definition: BeforeFileMovedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFolder
‪bool hasFolder($identifier)
Definition: ResourceStorage.php:2414
‪TYPO3\CMS\Core\Resource\Event\AfterFolderAddedEvent
Definition: AfterFolderAddedEvent.php:28
‪TYPO3\CMS\Core\Resource\Exception\ResourcePermissionsUnavailableException
Definition: ResourcePermissionsUnavailableException.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinFileMountBoundaries
‪bool isWithinFileMountBoundaries($subject, $checkWriteAccess=false)
Definition: ResourceStorage.php:595
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileContents
‪string getFileContents($file)
Definition: ResourceStorage.php:1696
‪TYPO3\CMS\Core\Resource\ResourceStorage\isDefault
‪bool isDefault()
Definition: ResourceStorage.php:2847
‪TYPO3\CMS\Core\Resource\ResourceStorage\isProcessingFolder
‪bool isProcessingFolder(Folder $folder)
Definition: ResourceStorage.php:1664
‪TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException
Definition: IllegalFileExtensionException.php:24
‪TYPO3\CMS\Core\Utility\PathUtility\basename
‪static basename(string $path)
Definition: PathUtility.php:219
‪TYPO3\CMS\Core\Resource\ResourceStorage\addUploadedFile
‪FileInterface addUploadedFile(array|UploadedFile $uploadedFileData, Folder $targetFolder=null, $targetFileName=null, $conflictMode=DuplicationBehavior::CANCEL)
Definition: ResourceStorage.php:2082
‪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:1529
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFile
‪bool hasFile($identifier)
Definition: ResourceStorage.php:1620
‪TYPO3\CMS\Core\Resource\ResourceStorage\setFileContents
‪int setFileContents(AbstractFile $file, $contents)
Definition: ResourceStorage.php:1769
‪TYPO3\CMS\Core\Resource\Capabilities\CAPABILITY_HIERARCHICAL_IDENTIFIERS
‪const CAPABILITY_HIERARCHICAL_IDENTIFIERS
Definition: Capabilities.php:40
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException
Definition: InsufficientFileAccessPermissionsException.php:24
‪TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException
Definition: InvalidTargetFolderException.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\getRootLevelFolder
‪Folder getRootLevelFolder($respectFileMounts=true)
Definition: ResourceStorage.php:2574
‪TYPO3\CMS\Core\Resource\Event\AfterFolderRenamedEvent
Definition: AfterFolderRenamedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\$folderIdentifiers
‪$folderIdentifiers
Definition: ResourceStorage.php:2377
‪TYPO3\CMS\Core\Resource\Exception\UploadException
Definition: UploadException.php:22
‪TYPO3\CMS\Core\Service\FlexFormService
Definition: FlexFormService.php:25
‪TYPO3\CMS\Core\Resource\Event\GeneratePublicUrlForResourceEvent
Definition: GeneratePublicUrlForResourceEvent.php:31
‪TYPO3\CMS\Core\Resource\ResourceStorage\$processingFolder
‪Folder null $processingFolder
Definition: ResourceStorage.php:183
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath(string $targetPath, bool $prefixWithSitePath=true)
Definition: PathUtility.php:52
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFileIdentifier
‪string hashFileIdentifier($file)
Definition: ResourceStorage.php:1314
‪TYPO3\CMS\Core\Resource\Folder\getParentFolder
‪getParentFolder()
Definition: Folder.php:511
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFile
‪FileInterface addFile($localFilePath, Folder $targetFolder, $targetFileName='', $conflictMode=DuplicationBehavior::RENAME, $removeOriginal=true)
Definition: ResourceStorage.php:1216
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Webhooks\Message\$publicUrl
‪identifier readonly string readonly string $publicUrl
Definition: FileUpdatedMessage.php:36
‪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:878
‪TYPO3\CMS\Core\Resource\Folder\getSubfolder
‪getSubfolder(string $name)
Definition: Folder.php:251
‪TYPO3\CMS\Core\Resource\ResourceStorage\$driver
‪Driver DriverInterface $driver
Definition: ResourceStorage.php:132
‪TYPO3\CMS\Core\Resource\ResourceStorage\isOnline
‪bool isOnline()
Definition: ResourceStorage.php:452
‪TYPO3\CMS\Core\Resource\InaccessibleFolder
Definition: InaccessibleFolder.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFolderActionPermission
‪bool checkFolderActionPermission($action, Folder $folder=null)
Definition: ResourceStorage.php:763
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:32
‪TYPO3\CMS\Core\Resource\ResourceStorage\setEvaluatePermissions
‪setEvaluatePermissions($evaluatePermissions)
Definition: ResourceStorage.php:638
‪TYPO3\CMS\Core\Resource\ResourceStorage\streamFile
‪streamFile(FileInterface $file, bool $asDownload=false, string $alternativeFilename=null, string $overrideMimeType=null)
Definition: ResourceStorage.php:1709
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFile
‪FileInterface moveFile($file, $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:1933
‪TYPO3\CMS\Core\Resource\AbstractFile
Definition: AbstractFile.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\getRole
‪string getRole(FolderInterface $folder)
Definition: ResourceStorage.php:2665
‪TYPO3\CMS\Core\Resource\ResourceStorage\markAsPermanentlyOffline
‪markAsPermanentlyOffline()
Definition: ResourceStorage.php:500
‪TYPO3\CMS\Core\Resource\AbstractFile\setIdentifier
‪$this setIdentifier($identifier)
Definition: AbstractFile.php:414
‪TYPO3\CMS\Core\Resource\Exception\InvalidConfigurationException
Definition: InvalidConfigurationException.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\getAllFileObjectsInFolder
‪File[] getAllFileObjectsInFolder(Folder $folder)
Definition: ResourceStorage.php:2122
‪TYPO3\CMS\Core\Resource\Capabilities\CAPABILITY_BROWSABLE
‪const CAPABILITY_BROWSABLE
Definition: Capabilities.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileMovePermissions
‪assureFileMovePermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
Definition: ResourceStorage.php:1029
‪TYPO3\CMS\Core\Resource\Search\Result\FileSearchResult
Definition: FileSearchResult.php:31
‪TYPO3\CMS\Core\Resource\ResourceStorage\getCapabilities
‪getCapabilities()
Definition: ResourceStorage.php:357
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderAddedEvent
Definition: BeforeFolderAddedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileAddPermissions
‪assureFileAddPermissions($targetFolder, $targetFileName)
Definition: ResourceStorage.php:974
‪TYPO3\CMS\Core\Resource\ResourceStorage\__construct
‪__construct(DriverInterface $driver, array $storageRecord, EventDispatcherInterface $eventDispatcher=null)
Definition: ResourceStorage.php:218
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileForLocalProcessing
‪string getFileForLocalProcessing(FileInterface $fileObject, $writable=true)
Definition: ResourceStorage.php:1389
‪TYPO3\CMS\Core\Resource\AbstractFile\getPublicUrl
‪string null getPublicUrl()
Definition: AbstractFile.php:533
‪TYPO3\CMS\Core\Resource\ResourceStorage\isBrowsable
‪bool isBrowsable()
Definition: ResourceStorage.php:401
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFolder
‪Folder createFolder($folderName, Folder $parentFolder=null)
Definition: ResourceStorage.php:2445
‪TYPO3\CMS\Core\Resource\Folder\createFolder
‪Folder createFolder($folderName)
Definition: Folder.php:336
‪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:22
‪TYPO3\CMS\Core\Resource\AbstractFile\getStorage
‪int< 0, getSize():int { if( $this->deleted) { throw new \RuntimeException( 'File has been deleted.', 1329821480);} if(empty( $this->properties[ 'size'])) { $fileInfo=$this-> getStorage() -> getFileInfoByIdentifier($this->getIdentifier(), ['size'])
‪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:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFile
‪FileInterface createFile($fileName, Folder $targetFolderObject)
Definition: ResourceStorage.php:1799
‪TYPO3\CMS\Core\Resource\Event\AfterFileRenamedEvent
Definition: AfterFileRenamedEvent.php:27
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:26
‪TYPO3\CMS\Core\Http\UploadedFile\getClientFilename
‪string null getClientFilename()
Definition: UploadedFile.php:227
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinFolder
‪bool isWithinFolder(Folder $folder, ResourceInterface $resource)
Definition: ResourceStorage.php:2554
‪TYPO3\CMS\Core\Resource\Event\AfterFileContentsSetEvent
Definition: AfterFileContentsSetEvent.php:28
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\RENAME
‪const RENAME
Definition: DuplicationBehavior.php:32
‪TYPO3\CMS\Core\Resource\Folder\getStorage
‪getStorage()
Definition: Folder.php:138
‪TYPO3\CMS\Core\Resource\Folder\checkActionPermission
‪bool checkActionPermission($action)
Definition: Folder.php:400
‪TYPO3\CMS\Core\Resource\ResourceStorage\autoExtractMetadataEnabled
‪bool autoExtractMetadataEnabled()
Definition: ResourceStorage.php:488
‪TYPO3\CMS\Core\Resource\Service\FileProcessingService\processFile
‪processFile(File|FileReference $fileObject, string $taskType, DriverInterface $driver, array $configuration)
Definition: FileProcessingService.php:56
‪TYPO3\CMS\Core\Utility\GeneralUtility\hmac
‪static string hmac($input, $additionalSecret='')
Definition: GeneralUtility.php:475
‪TYPO3\CMS\Core\Resource\FolderInterface\hasFile
‪hasFile(string $name)
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileDeletePermissions
‪assureFileDeletePermissions(FileInterface $file)
Definition: ResourceStorage.php:937
‪TYPO3\CMS\Core\Resource\ResourceStorage\getConfiguration
‪array getConfiguration()
Definition: ResourceStorage.php:277
‪TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: AbstractFile.php:426
‪TYPO3\CMS\Core\Resource\Event\AfterFileCopiedEvent
Definition: AfterFileCopiedEvent.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasChildren
‪bool hasChildren()
Definition: ResourceStorage.php:346
‪TYPO3\CMS\Core\Resource\ResourceInterface\getParentFolder
‪getParentFolder()
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:64
‪TYPO3\CMS\Core\Resource\Folder\getName
‪getName()
Definition: Folder.php:88
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileMounts
‪array getFileMounts()
Definition: ResourceStorage.php:582
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_PROCESSING
‪const ROLE_PROCESSING
Definition: FolderInterface.php:30
‪TYPO3\CMS\Core\Resource\Folder\getRole
‪string getRole()
Definition: Folder.php:497
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinProcessingFolder
‪bool isWithinProcessingFolder($identifier)
Definition: ResourceStorage.php:2536
‪TYPO3\CMS\Core\Resource\Index\Indexer\createIndexEntry
‪createIndexEntry($identifier)
Definition: Indexer.php:64
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasHierarchicalIdentifiers
‪hasHierarchicalIdentifiers()
Definition: ResourceStorage.php:409
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFolderBetweenStorages
‪moveFolderBetweenStorages(Folder $folderToMove, Folder $targetParentFolder, $newFolderName)
Definition: ResourceStorage.php:2201
‪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:201
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderCopyPermissions
‪assureFolderCopyPermissions(FolderInterface $folderToCopy, FolderInterface $targetParentFolder)
Definition: ResourceStorage.php:1121
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_MOUNT
‪const ROLE_MOUNT
Definition: FolderInterface.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileProcessingService
‪Service FileProcessingService $fileProcessingService
Definition: ResourceStorage.php:148
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNamesForNestedProcessingFolder
‪string[] getNamesForNestedProcessingFolder($fileIdentifier, $levels)
Definition: ResourceStorage.php:2803
‪TYPO3\CMS\Core\Resource\ResourceStorage\$folders
‪foreach($folderIdentifiers as $folderIdentifier) return $folders
Definition: ResourceStorage.php:2388
‪TYPO3\CMS\Core\Resource\Search\Result\FileSearchResultInterface
Definition: FileSearchResultInterface.php:25
‪TYPO3\CMS\Core\Resource\ResourceStorage\sanitizeFileName
‪string sanitizeFileName($fileName, Folder $targetFolder=null)
Definition: ResourceStorage.php:1187
‪TYPO3\CMS\Core\Resource\Capabilities\CAPABILITY_WRITABLE
‪const CAPABILITY_WRITABLE
Definition: Capabilities.php:36
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFolderObject
‪Folder createFolderObject(string $identifier, string $name)
Definition: ResourceStorage.php:2913
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_USER_MOUNT
‪const ROLE_USER_MOUNT
Definition: FolderInterface.php:35
‪TYPO3\CMS\Core\Resource\ResourceStorage\$isDefault
‪bool $isDefault
Definition: ResourceStorage.php:199
‪TYPO3\CMS\Core\Resource
Definition: generateMimeTypes.php:52
‪TYPO3\CMS\Core\Resource\ProcessedFile
Definition: ProcessedFile.php:47
‪TYPO3\CMS\Core\Resource\ResourceStorage\$this
‪return $this
Definition: ResourceStorage.php:1502
‪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\Resource\ResourceStorage\assureFolderReadPermission
‪assureFolderReadPermission(Folder $folder=null)
Definition: ResourceStorage.php:826
‪TYPO3\CMS\Core\Resource\ResourceStorage\usesCaseSensitiveIdentifiers
‪bool usesCaseSensitiveIdentifiers()
Definition: ResourceStorage.php:442
‪TYPO3\CMS\Core\Resource\Exception
Definition: Exception.php:22
‪TYPO3\CMS\Core\Http\FalDumpFileContentsDecoratorStream
Definition: FalDumpFileContentsDecoratorStream.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFileInFolder
‪bool hasFileInFolder($fileName, Folder $folder)
Definition: ResourceStorage.php:1682
‪TYPO3\CMS\Core\Resource\ResourceStorage\$capabilities
‪Capabilities $capabilities
Definition: ResourceStorage.php:175
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_READONLY_MOUNT
‪const ROLE_READONLY_MOUNT
Definition: FolderInterface.php:34
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileCopyPermissions
‪assureFileCopyPermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
Definition: ResourceStorage.php:1089
‪TYPO3\CMS\Core\Resource\ResourceStorage\$evaluatePermissions
‪bool $evaluatePermissions
Definition: ResourceStorage.php:157
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:127
‪TYPO3\CMS\Core\Resource\ResourceStorage\setDriver
‪ResourceStorage setDriver(DriverInterface $driver)
Definition: ResourceStorage.php:305
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderCopiedEvent
Definition: BeforeFolderCopiedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getPseudoStream
‪ResponseInterface getPseudoStream(FileInterface $file, bool $asDownload=false, string $alternativeFilename=null, string $overrideMimeType=null)
Definition: ResourceStorage.php:1735
‪$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:1155
‪TYPO3\CMS\Core\Resource\ResourceStorage\isPublic
‪bool isPublic()
Definition: ResourceStorage.php:380
‪TYPO3\CMS\Core\Log\LogManager
Definition: LogManager.php:33
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪if
‪if(PHP_SAPI !=='cli')
Definition: checkNamespaceIntegrity.php:25
‪TYPO3\CMS\Core\Resource\Folder\hasFolder
‪hasFolder(string $name)
Definition: Folder.php:389
‪TYPO3\CMS\Core\Http\UploadedFile
Definition: UploadedFile.php:34
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNearestRecyclerFolder
‪Folder null getNearestRecyclerFolder(FileInterface $file)
Definition: ResourceStorage.php:2873
‪TYPO3\CMS\Core\Resource\ResourceStorage\countFoldersInFolder
‪int countFoldersInFolder(Folder $folder, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:2401
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_RECYCLER
‪const ROLE_RECYCLER
Definition: FolderInterface.php:29
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException
Definition: InsufficientFolderWritePermissionsException.php:22
‪TYPO3\CMS\Core\Resource\FolderInterface
Definition: FolderInterface.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFile
‪string hashFile(FileInterface $fileObject, $hash)
Definition: ResourceStorage.php:1284
‪TYPO3\CMS\Core\Resource\ResourceStorage\setConfiguration
‪setConfiguration(array $configuration)
Definition: ResourceStorage.php:285
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFileObject
‪File getFileObject($uid, array $fileData=[])
Definition: ResourceFactory.php:192
‪TYPO3\CMS\Core\Resource\ResourceStorage\updateProcessedFile
‪FileInterface updateProcessedFile($localFilePath, ProcessedFile $processedFile, Folder $processingFolder=null)
Definition: ResourceStorage.php:1263
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileRenamePermissions
‪assureFileRenamePermissions(FileInterface $file, $targetFileName)
Definition: ResourceStorage.php:1058
‪TYPO3\CMS\Core\Utility\Exception\NotImplementedMethodException
Definition: NotImplementedMethodException.php:27
‪TYPO3\CMS\Core\Resource\Filter\ImportExportFilter
Definition: ImportExportFilter.php:31
‪TYPO3\CMS\Core\Resource\ResourceStorage\$folders
‪foreach($this->getProcessingFolders() as $processingFolder) $folders
Definition: ResourceStorage.php:2387
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileWritePermissions
‪assureFileWritePermissions(FileInterface $file)
Definition: ResourceStorage.php:901
‪TYPO3\CMS\Core\Resource\Folder\getIdentifier
‪non empty string getIdentifier()
Definition: Folder.php:149
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\REPLACE
‪const REPLACE
Definition: DuplicationBehavior.php:39
‪TYPO3\CMS\Core\Resource\ResourceInterface
Definition: ResourceInterface.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWritable
‪bool isWritable()
Definition: ResourceStorage.php:391
‪TYPO3\CMS\Core\Resource\Folder\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: Folder.php:165
‪TYPO3\CMS\Core\Http\fromRequest
‪@ fromRequest
Definition: ApplicationType.php:67
‪TYPO3\CMS\Core\Resource\ResourceStorage\$userPermissions
‪array $userPermissions
Definition: ResourceStorage.php:170
‪TYPO3\CMS\Core\Resource\Service\FileProcessingService
Definition: FileProcessingService.php:48
‪TYPO3\CMS\Core\Resource\Event\SanitizeFileNameEvent
Definition: SanitizeFileNameEvent.php:29
‪TYPO3\CMS\Core\Resource\AbstractFile\updateProperties
‪updateProperties(array $properties)
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:51
‪TYPO3\CMS\Core\Resource\ResourceStorage\unsetFileAndFolderNameFilters
‪unsetFileAndFolderNameFilters()
Definition: ResourceStorage.php:1460
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderMovedEvent
Definition: BeforeFolderMovedEvent.php:28
‪TYPO3\CMS\Core\Resource\ProcessedFile\getName
‪non empty string getName()
Definition: ProcessedFile.php:329
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileActionPermission
‪bool checkFileActionPermission($action, FileInterface $file)
Definition: ResourceStorage.php:696
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasCapability
‪hasCapability(int $capability)
Definition: ResourceStorage.php:367
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException
Definition: FileOperationErrorException.php:22
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderIdentifiersInFolder
‪array getFolderIdentifiersInFolder($folderIdentifier, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1608
‪TYPO3\CMS\Core\Resource\Event\AfterFileReplacedEvent
Definition: AfterFileReplacedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkUserActionPermission
‪bool checkUserActionPermission($action, $type)
Definition: ResourceStorage.php:670
‪TYPO3\CMS\Core\Resource\Event\AfterFolderDeletedEvent
Definition: AfterFolderDeletedEvent.php:27
‪TYPO3\CMS\Core\Http\UploadedFile\getTemporaryFileName
‪getTemporaryFileName()
Definition: UploadedFile.php:238
‪TYPO3\CMS\Core\Resource\FileReference\getStorage
‪getStorage()
Definition: FileReference.php:349
‪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\getPublicUrl
‪string null getPublicUrl(ResourceInterface $resourceObject)
Definition: ResourceStorage.php:1332
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUniqueName
‪string getUniqueName(FolderInterface $folder, $theFile, $dontCheckForUnique=false)
Definition: ResourceStorage.php:2597
‪TYPO3\CMS\Core\Resource\AbstractFile\getIdentifier
‪getIdentifier()
Definition: AbstractFile.php:137
‪TYPO3\CMS\Core\Resource\ResourceStorage\deleteFile
‪bool deleteFile($fileObject)
Definition: ResourceStorage.php:1820
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderDeletePermission
‪assureFolderDeletePermission(Folder $folder, $checkDeleteRecursively)
Definition: ResourceStorage.php:851
‪TYPO3\CMS\Core\Resource\Exception\InvalidHashException
Definition: InvalidHashException.php:27
‪TYPO3\CMS\Core\Resource\Event\BeforeFileContentsSetEvent
Definition: BeforeFileContentsSetEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\getIndexer
‪Index Indexer getIndexer()
Definition: ResourceStorage.php:2831
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFolderInFolder
‪bool hasFolderInFolder($folderName, Folder $folder)
Definition: ResourceStorage.php:2426
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileIndexRepository
‪Index FileIndexRepository getFileIndexRepository()
Definition: ResourceStorage.php:2643
‪TYPO3\CMS\Core\Utility\PathUtility\pathinfo
‪static string string[] pathinfo(string $path, int $options=PATHINFO_ALL)
Definition: PathUtility.php:270
‪TYPO3\CMS\Core\Resource\ResourceStorage\copyFolder
‪Folder copyFolder(FolderInterface $folderToCopy, FolderInterface $targetParentFolder, $newFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2216
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static getUniqueId(string $prefix='')
Definition: StringUtility.php:57
‪TYPO3\CMS\Core\Http\ApplicationType
‪ApplicationType
Definition: ApplicationType.php:56
‪TYPO3\CMS\Core\Resource\Event\AfterFileAddedEvent
Definition: AfterFileAddedEvent.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\setDefault
‪setDefault($isDefault)
Definition: ResourceStorage.php:2839
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository\findOneByStorageAndIdentifier
‪array bool findOneByStorageAndIdentifier(ResourceStorage $storage, $identifier)
Definition: FileIndexRepository.php:124
‪TYPO3\CMS\Core\Resource\ResourceStorage\getName
‪string getName()
Definition: ResourceStorage.php:326
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileMounts
‪array $fileMounts
Definition: ResourceStorage.php:163
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileUploadPermissions
‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileSize)
Definition: ResourceStorage.php:1005
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNestedProcessingFolder
‪Folder getNestedProcessingFolder(File $file, Folder $rootProcessingFolder)
Definition: ResourceStorage.php:2771
‪TYPO3\CMS\Core\Http\UploadedFile\getSize
‪int null getSize()
Definition: UploadedFile.php:193