‪TYPO3CMS  10.4
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;
88 
122 {
128  protected ‪$driver;
129 
135  protected ‪$storageRecord;
136 
142  protected ‪$configuration;
143 
147  protected ‪$fileProcessingService;
148 
157  protected ‪$evaluatePermissions = false;
158 
164  protected ‪$fileMounts = [];
165 
172  protected ‪$userPermissions = [];
173 
180  protected ‪$capabilities;
181 
185  protected ‪$eventDispatcher;
186 
190  protected ‪$processingFolder;
191 
197  protected ‪$processingFolders;
198 
204  protected ‪$isOnline;
205 
209  protected ‪$isDefault = false;
210 
217 
221  const ‪PROCESSING_FOLDER_LEVELS = 2;
222 
230  public function ‪__construct(‪DriverInterface ‪$driver, array ‪$storageRecord, EventDispatcherInterface ‪$eventDispatcher = null)
231  {
232  $this->storageRecord = ‪$storageRecord;
233  $this->eventDispatcher = ‪$eventDispatcher ?? GeneralUtility::getContainer()->get(EventDispatcherInterface::class);
234  $this->configuration = $this->‪getResourceFactoryInstance()->‪convertFlexFormDataToConfigurationArray($storageRecord['configuration'] ?? '');
235  $this->capabilities =
236  ($this->storageRecord['is_browsable'] ?? null ? ‪self::CAPABILITY_BROWSABLE : 0) |
237  ($this->storageRecord['is_public'] ?? null ? self::CAPABILITY_PUBLIC : 0) |
238  ($this->storageRecord['is_writable'] ?? null ? ‪self::CAPABILITY_WRITABLE : 0) |
239  // Always let the driver decide whether to set this capability
240  self::CAPABILITY_HIERARCHICAL_IDENTIFIERS;
241 
242  $this->driver = ‪$driver;
243  $this->driver->‪setStorageUid(‪$storageRecord['uid'] ?? null);
244  $this->driver->mergeConfigurationCapabilities($this->capabilities);
245  try {
246  $this->driver->processConfiguration();
247  } catch (‪InvalidConfigurationException $e) {
248  // Configuration error
249  $this->‪isOnline = false;
250 
251  $message = sprintf(
252  'Failed initializing storage [%d] "%s", error: %s',
253  $this->‪getUid(),
254  $this->‪getName(),
255  $e->getMessage()
256  );
257 
258  // create a dedicated logger instance because we need a logger in the constructor
259  GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class)->error($message);
260  }
261  $this->driver->initialize();
262  $this->capabilities = $this->driver->getCapabilities();
263 
264  $this->‪isDefault = (isset(‪$storageRecord['is_default']) && ‪$storageRecord['is_default'] == 1);
266  }
267 
273  public function ‪getConfiguration()
274  {
276  }
277 
283  public function ‪setConfiguration(array ‪$configuration)
284  {
285  $this->configuration = ‪$configuration;
286  }
287 
293  public function ‪getStorageRecord()
294  {
296  }
297 
304  public function ‪setDriver(DriverInterface ‪$driver)
305  {
306  $this->driver = ‪$driver;
307  return ‪$this;
308  }
309 
315  protected function ‪getDriver()
316  {
317  return ‪$this->driver;
318  }
319 
325  public function ‪getName()
326  {
327  return $this->storageRecord['name'];
328  }
329 
335  public function ‪getUid()
336  {
337  return (int)($this->storageRecord['uid'] ?? 0);
338  }
339 
345  public function ‪hasChildren()
346  {
347  return true;
348  }
349 
350  /*********************************
351  * Capabilities
352  ********************************/
362  public function ‪getCapabilities()
363  {
364  return (int)‪$this->capabilities;
365  }
366 
373  protected function ‪hasCapability($capability)
374  {
375  return ($this->capabilities & $capability) == $capability;
376  }
377 
386  public function ‪isPublic()
387  {
388  return $this->‪hasCapability(self::CAPABILITY_PUBLIC);
389  }
390 
397  public function ‪isWritable()
398  {
399  return $this->‪hasCapability(self::CAPABILITY_WRITABLE);
400  }
401 
407  public function ‪isBrowsable()
408  {
409  return $this->‪isOnline() && $this->‪hasCapability(self::CAPABILITY_BROWSABLE);
410  }
411 
417  public function ‪hasHierarchicalIdentifiers(): bool
418  {
419  return $this->‪hasCapability(self::CAPABILITY_HIERARCHICAL_IDENTIFIERS);
420  }
421 
431  public function ‪searchFiles(‪FileSearchDemand $searchDemand, ‪Folder $folder = null, bool $useFilters = true): ‪FileSearchResultInterface
432  {
433  $folder = $folder ?? $this->‪getRootLevelFolder();
434  if (!$folder->checkActionPermission('read')) {
435  return new ‪EmptyFileSearchResult();
436  }
437 
440  $searchDemand->‪withFolder($folder)
441  ),
442  ‪$this->driver,
443  $useFilters ? ‪$this->getFileAndFolderNameFilters() : []
444  );
445  }
446 
452  public function ‪usesCaseSensitiveIdentifiers()
453  {
454  return $this->driver->isCaseSensitiveFileSystem();
455  }
456 
462  public function ‪isOnline()
463  {
464  if ($this->‪isOnline === null) {
465  if ($this->‪getUid() === 0) {
466  $this->‪isOnline = true;
467  }
468  // the storage is not marked as online for a longer time
469  if ($this->storageRecord['is_online'] == 0) {
470  $this->‪isOnline = false;
471  }
472  if ($this->‪isOnline !== false) {
473  // all files are ALWAYS available in the frontend
474  if (TYPO3_MODE === 'FE') {
475  $this->‪isOnline = true;
476  } else {
477  // check if the storage is disabled temporary for now
478  $registryObject = GeneralUtility::makeInstance(Registry::class);
479  $offlineUntil = $registryObject->get('core', 'sys_file_storage-' . $this->‪getUid() . '-offline-until');
480  if ($offlineUntil && $offlineUntil > time()) {
481  $this->‪isOnline = false;
482  } else {
483  $this->‪isOnline = true;
484  }
485  }
486  }
487  }
488  return ‪$this->isOnline;
489  }
490 
496  public function ‪autoExtractMetadataEnabled()
497  {
498  return !empty($this->storageRecord['auto_extract_metadata']);
499  }
500 
508  public function ‪markAsPermanentlyOffline()
509  {
510  if ($this->‪getUid() > 0) {
511  // @todo: move this to the storage repository
512  GeneralUtility::makeInstance(ConnectionPool::class)
513  ->getConnectionForTable('sys_file_storage')
514  ->update(
515  'sys_file_storage',
516  ['is_online' => 0],
517  ['uid' => (int)$this->‪getUid()]
518  );
519  }
520  $this->storageRecord['is_online'] = 0;
521  $this->‪isOnline = false;
522  }
523 
530  public function ‪markAsTemporaryOffline()
531  {
532  $registryObject = GeneralUtility::makeInstance(Registry::class);
533  $registryObject->set('core', 'sys_file_storage-' . $this->‪getUid() . '-offline-until', time() + 60 * 5);
534  $this->storageRecord['is_online'] = 0;
535  $this->‪isOnline = false;
536  }
537 
538  /*********************************
539  * User Permissions / File Mounts
540  ********************************/
550  public function ‪addFileMount($folderIdentifier, $additionalData = [])
551  {
552  // check for the folder before we add it as a filemount
553  if ($this->driver->folderExists($folderIdentifier) === false) {
554  // if there is an error, this is important and should be handled
555  // as otherwise the user would see the whole storage without any restrictions for the filemounts
556  throw new ‪FolderDoesNotExistException('Folder for file mount ' . $folderIdentifier . ' does not exist.', 1334427099);
557  }
558  $data = $this->driver->getFolderInfoByIdentifier($folderIdentifier);
559  $folderObject = $this->‪getResourceFactoryInstance()->‪createFolderObject(‪$this, $data['identifier'], $data['name']);
560  // Use the canonical identifier instead of the user provided one!
561  $folderIdentifier = $folderObject->‪getIdentifier();
562  if (
563  !empty($this->fileMounts[$folderIdentifier])
564  && empty($this->fileMounts[$folderIdentifier]['read_only'])
565  && !empty($additionalData['read_only'])
566  ) {
567  // Do not overwrite a regular mount with a read only mount
568  return;
569  }
570  if (empty($additionalData)) {
571  $additionalData = [
572  'path' => $folderIdentifier,
573  'title' => $folderIdentifier,
574  'folder' => $folderObject
575  ];
576  } else {
577  $additionalData['folder'] = $folderObject;
578  if (!isset($additionalData['title'])) {
579  $additionalData['title'] = $folderIdentifier;
580  }
581  }
582  $this->fileMounts[$folderIdentifier] = $additionalData;
583  }
584 
590  public function ‪getFileMounts()
591  {
592  return ‪$this->fileMounts;
593  }
594 
603  public function ‪isWithinFileMountBoundaries($subject, $checkWriteAccess = false)
604  {
605  if (!$this->evaluatePermissions) {
606  return true;
607  }
608  $isWithinFileMount = false;
609  if (!$subject) {
610  $subject = $this->‪getRootLevelFolder();
611  }
612  $identifier = $subject->getIdentifier();
613 
614  // Allow access to processing folder
615  if ($this->‪isWithinProcessingFolder($identifier)) {
616  $isWithinFileMount = true;
617  } else {
618  // Check if the identifier of the subject is within at
619  // least one of the file mounts
620  $writableFileMountAvailable = false;
621  foreach ($this->fileMounts as $fileMount) {
623  $folder = $fileMount['folder'];
624  if ($this->driver->isWithin($folder->getIdentifier(), $identifier)) {
625  $isWithinFileMount = true;
626  if (!$checkWriteAccess) {
627  break;
628  }
629  if (empty($fileMount['read_only'])) {
630  $writableFileMountAvailable = true;
631  break;
632  }
633  }
634  }
635  $isWithinFileMount = $checkWriteAccess ? $writableFileMountAvailable : $isWithinFileMount;
636  }
637  return $isWithinFileMount;
638  }
639 
647  {
648  $this->evaluatePermissions = (bool)‪$evaluatePermissions;
649  }
650 
657  public function ‪getEvaluatePermissions()
658  {
660  }
661 
667  public function ‪setUserPermissions(array ‪$userPermissions)
668  {
669  $this->userPermissions = ‪$userPermissions;
670  }
671 
680  public function ‪checkUserActionPermission($action, $type)
681  {
682  if (!$this->evaluatePermissions) {
683  return true;
684  }
685 
686  $allow = false;
687  if (!empty($this->userPermissions[strtolower($action) . ucfirst(strtolower($type))])) {
688  $allow = true;
689  }
690 
691  return $allow;
692  }
693 
707  public function ‪checkFileActionPermission($action, ‪FileInterface $file)
708  {
709  $isProcessedFile = $file instanceof ‪ProcessedFile;
710  // Check 1: Allow editing meta data of a file if it is in mount boundaries of a writable file mount
711  if ($action === 'editMeta') {
712  return !$isProcessedFile && $this->‪isWithinFileMountBoundaries($file, true);
713  }
714  // Check 2: Does the user have permission to perform the action? e.g. "readFile"
715  if (!$isProcessedFile && $this->‪checkUserActionPermission($action, 'File') === false) {
716  return false;
717  }
718  // Check 3: No action allowed on files for denied file extensions
719  if (!$this->‪checkFileExtensionPermission($file->‪getName())) {
720  return false;
721  }
722  $isReadCheck = false;
723  if (in_array($action, ['read', 'copy', 'move', 'replace'], true)) {
724  $isReadCheck = true;
725  }
726  $isWriteCheck = false;
727  if (in_array($action, ['add', 'write', 'move', 'rename', 'replace', 'delete'], true)) {
728  $isWriteCheck = true;
729  }
730  // Check 4: Does the user have the right to perform the action?
731  // (= is he within the file mount borders)
732  if (!$isProcessedFile && !$this->‪isWithinFileMountBoundaries($file, $isWriteCheck)) {
733  return false;
734  }
735 
736  $isMissing = false;
737  if (!$isProcessedFile && $file instanceof ‪File) {
738  $isMissing = $file->isMissing();
739  }
740 
741  if ($this->driver->fileExists($file->‪getIdentifier()) === false) {
742  $file->setMissing(true);
743  $isMissing = true;
744  }
745 
746  // Check 5: Check the capabilities of the storage (and the driver)
747  if ($isWriteCheck && ($isMissing || !$this->‪isWritable())) {
748  return false;
749  }
750 
751  // Check 6: "File permissions" of the driver (only when file isn't marked as missing)
752  if (!$isMissing) {
753  $filePermissions = $this->driver->getPermissions($file->‪getIdentifier());
754  if ($isReadCheck && !$filePermissions['r']) {
755  return false;
756  }
757  if ($isWriteCheck && !$filePermissions['w']) {
758  return false;
759  }
760  }
761  return true;
762  }
763 
774  public function ‪checkFolderActionPermission($action, Folder $folder = null)
775  {
776  // Check 1: Does the user have permission to perform the action? e.g. "writeFolder"
777  if ($this->‪checkUserActionPermission($action, 'Folder') === false) {
778  return false;
779  }
780 
781  // If we do not have a folder here, we cannot do further checks
782  if ($folder === null) {
783  return true;
784  }
785 
786  $isReadCheck = false;
787  if (in_array($action, ['read', 'copy'], true)) {
788  $isReadCheck = true;
789  }
790  $isWriteCheck = false;
791  if (in_array($action, ['add', 'move', 'write', 'delete', 'rename'], true)) {
792  $isWriteCheck = true;
793  }
794  // Check 2: Does the user has the right to perform the action?
795  // (= is he within the file mount borders)
796  if (!$this->‪isWithinFileMountBoundaries($folder, $isWriteCheck)) {
797  return false;
798  }
799  // Check 3: Check the capabilities of the storage (and the driver)
800  if ($isReadCheck && !$this->‪isBrowsable()) {
801  return false;
802  }
803  if ($isWriteCheck && !$this->‪isWritable()) {
804  return false;
805  }
806 
807  // Check 4: "Folder permissions" of the driver
808  $folderPermissions = $this->driver->getPermissions($folder->getIdentifier());
809  if ($isReadCheck && !$folderPermissions['r']) {
810  return false;
811  }
812  if ($isWriteCheck && !$folderPermissions['w']) {
813  return false;
814  }
815  return true;
816  }
817 
823  public function ‪checkFileAndFolderNameFilters(ResourceInterface $fileOrFolder)
824  {
825  trigger_error(__METHOD__ . ' is deprecated. This method will be removed without substitution, use the ResourceStorage API instead', \E_USER_DEPRECATED);
826  foreach ($this->getFileAndFolderNameFilters() as $filter) {
827  if (is_callable($filter)) {
828  $result = call_user_func($filter, $fileOrFolder->getName(), $fileOrFolder->getIdentifier(), $fileOrFolder->getParentFolder()->getIdentifier(), [], ‪$this->driver);
829  // We have to use -1 as the „don't include“ return value, as call_user_func() will return FALSE
830  // If calling the method succeeded and thus we can't use that as a return value.
831  if ($result === -1) {
832  return false;
833  }
834  if ($result === false) {
835  throw new \RuntimeException(
836  'Could not apply file/folder name filter ' . $filter[0] . '::' . $filter[1],
837  1525342106
838  );
839  }
840  }
841  }
842 
843  return true;
844  }
845 
853  protected function ‪checkFileExtensionPermission($fileName)
854  {
855  $fileName = $this->driver->sanitizeFileName($fileName);
856  return GeneralUtility::makeInstance(FileNameValidator::class)->isValid($fileName);
857  }
858 
865  protected function ‪assureFolderReadPermission(Folder $folder = null)
866  {
867  if (!$this->‪checkFolderActionPermission('read', $folder)) {
868  if ($folder === null) {
869  throw new InsufficientFolderAccessPermissionsException(
870  'You are not allowed to read folders',
871  1430657869
872  );
873  }
874  throw new InsufficientFolderAccessPermissionsException(
875  'You are not allowed to access the given folder: "' . $folder->getName() . '"',
876  1375955684
877  );
878  }
879  }
880 
890  protected function ‪assureFolderDeletePermission(Folder $folder, $checkDeleteRecursively)
891  {
892  // Check user permissions for recursive deletion if it is requested
893  if ($checkDeleteRecursively && !$this->‪checkUserActionPermission('recursivedelete', 'Folder')) {
894  throw new InsufficientUserPermissionsException('You are not allowed to delete folders recursively', 1377779423);
895  }
896  // Check user action permission
897  if (!$this->‪checkFolderActionPermission('delete', $folder)) {
898  throw new InsufficientFolderAccessPermissionsException(
899  'You are not allowed to delete the given folder: "' . $folder->getName() . '"',
900  1377779039
901  );
902  }
903  // Check if the user has write permissions to folders
904  // Would be good if we could check for actual write permissions in the containing folder
905  // but we cannot since we have no access to the containing folder of this file.
906  if (!$this->‪checkUserActionPermission('write', 'Folder')) {
907  throw new ‪InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377779111);
908  }
909  }
910 
918  protected function ‪assureFileReadPermission(FileInterface $file)
919  {
920  if (!$this->‪checkFileActionPermission('read', $file)) {
921  throw new InsufficientFileAccessPermissionsException(
922  'You are not allowed to access that file: "' . $file->getName() . '"',
923  1375955429
924  );
925  }
926  if (!$this->‪checkFileExtensionPermission($file->getName())) {
927  throw new IllegalFileExtensionException(
928  'You are not allowed to use that file extension. File: "' . $file->getName() . '"',
929  1375955430
930  );
931  }
932  }
933 
942  protected function ‪assureFileWritePermissions(FileInterface $file)
943  {
944  // Check if user is allowed to write the file and $file is writable
945  if (!$this->‪checkFileActionPermission('write', $file)) {
946  throw new ‪InsufficientFileWritePermissionsException('Writing to file "' . $file->getIdentifier() . '" is not allowed.', 1330121088);
947  }
948  if (!$this->‪checkFileExtensionPermission($file->getName())) {
949  throw new ‪IllegalFileExtensionException('You are not allowed to edit a file with extension "' . $file->getExtension() . '"', 1366711933);
950  }
951  }
952 
960  protected function ‪assureFileReplacePermissions(FileInterface $file)
961  {
962  // Check if user is allowed to replace the file and $file is writable
963  if (!$this->‪checkFileActionPermission('replace', $file)) {
964  throw new InsufficientFileWritePermissionsException('Replacing file "' . $file->getIdentifier() . '" is not allowed.', 1436899571);
965  }
966  // Check if parentFolder is writable for the user
967  if (!$this->‪checkFolderActionPermission('write', $file->getParentFolder())) {
968  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $file->getIdentifier() . '"', 1436899572);
969  }
970  }
971 
980  protected function ‪assureFileDeletePermissions(FileInterface $file)
981  {
982  // Check for disallowed file extensions
983  if (!$this->‪checkFileExtensionPermission($file->getName())) {
984  throw new IllegalFileExtensionException('You are not allowed to delete a file with extension "' . $file->getExtension() . '"', 1377778916);
985  }
986  // Check further permissions if file is not a processed file
987  if (!$file instanceof ProcessedFile) {
988  // Check if user is allowed to delete the file and $file is writable
989  if (!$this->‪checkFileActionPermission('delete', $file)) {
990  throw new InsufficientFileWritePermissionsException('You are not allowed to delete the file "' . $file->getIdentifier() . '"', 1319550425);
991  }
992  // Check if the user has write permissions to folders
993  // Would be good if we could check for actual write permissions in the containing folder
994  // but we cannot since we have no access to the containing folder of this file.
995  if (!$this->‪checkUserActionPermission('write', 'Folder')) {
996  throw new InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377778702);
997  }
998  }
999  }
1000 
1012  protected function ‪assureFileAddPermissions($targetFolder, $targetFileName)
1013  {
1014  // Check for a valid file extension
1015  if (!$this->‪checkFileExtensionPermission($targetFileName)) {
1016  throw new IllegalFileExtensionException('Extension of file name is not allowed in "' . $targetFileName . '"!', 1322120271);
1017  }
1018  // Makes sure the user is allowed to upload
1019  if (!$this->‪checkUserActionPermission('add', 'File')) {
1020  throw new InsufficientUserPermissionsException('You are not allowed to add files to this storage "' . $this->‪getUid() . '"', 1376992145);
1021  }
1022  // Check if targetFolder is writable
1023  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1024  throw new InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetFolder->getIdentifier() . '"', 1322120356);
1025  }
1026  }
1027 
1043  protected function ‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileSize)
1044  {
1045  // Makes sure this is an uploaded file
1046  if (!is_uploaded_file($localFilePath)) {
1047  throw new UploadException('The upload has failed, no uploaded file found!', 1322110455);
1048  }
1049  // Max upload size (kb) for files.
1050  $maxUploadFileSize = GeneralUtility::getMaxUploadFileSize() * 1024;
1051  if ($maxUploadFileSize > 0 && $uploadedFileSize >= $maxUploadFileSize) {
1052  unlink($localFilePath);
1053  throw new UploadSizeException('The uploaded file exceeds the size-limit of ' . $maxUploadFileSize . ' bytes', 1322110041);
1054  }
1055  $this->‪assureFileAddPermissions($targetFolder, $targetFileName);
1056  }
1057 
1069  protected function ‪assureFileMovePermissions(‪FileInterface $file, ‪Folder $targetFolder, $targetFileName)
1070  {
1071  // Check if targetFolder is within this storage
1072  if ($this->‪getUid() !== $targetFolder->‪getStorage()->‪getUid()) {
1073  throw new \RuntimeException('The target folder is not in the same storage. Target folder given: "' . $targetFolder->‪getIdentifier() . '"', 1422553107);
1074  }
1075  // Check for a valid file extension
1076  if (!$this->‪checkFileExtensionPermission($targetFileName)) {
1077  throw new IllegalFileExtensionException('Extension of file name is not allowed in "' . $targetFileName . '"!', 1378243279);
1078  }
1079  // Check if user is allowed to move and $file is readable and writable
1080  if (!$file->‪getStorage()->‪checkFileActionPermission('move', $file)) {
1081  throw new InsufficientUserPermissionsException('You are not allowed to move files to storage "' . $this->‪getUid() . '"', 1319219349);
1082  }
1083  // Check if target folder is writable
1084  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1085  throw new ‪InsufficientFolderAccessPermissionsException('You are not allowed to write to the target folder "' . $targetFolder->‪getIdentifier() . '"', 1319219350);
1086  }
1087  }
1088 
1099  protected function ‪assureFileRenamePermissions(FileInterface $file, $targetFileName)
1100  {
1101  // Check if file extension is allowed
1102  if (!$this->‪checkFileExtensionPermission($targetFileName) || !$this->‪checkFileExtensionPermission($file->getName())) {
1103  throw new IllegalFileExtensionException('You are not allowed to rename a file with this extension. File given: "' . $file->getName() . '"', 1371466663);
1104  }
1105  // Check if user is allowed to rename
1106  if (!$this->‪checkFileActionPermission('rename', $file)) {
1107  throw new InsufficientUserPermissionsException('You are not allowed to rename files. File given: "' . $file->getName() . '"', 1319219351);
1108  }
1109  // Check if the user is allowed to write to folders
1110  // Although it would be good to check, we cannot check here if the folder actually is writable
1111  // because we do not know in which folder the file resides.
1112  // So we rely on the driver to throw an exception in case the renaming failed.
1113  if (!$this->‪checkFolderActionPermission('write')) {
1114  throw new InsufficientFileWritePermissionsException('You are not allowed to write to folders', 1319219352);
1115  }
1116  }
1117 
1132  protected function ‪assureFileCopyPermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
1133  {
1134  // Check if targetFolder is within this storage, this should never happen
1135  if ($this->‪getUid() != $targetFolder->getStorage()->getUid()) {
1136  throw new Exception('The operation of the folder cannot be called by this storage "' . $this->‪getUid() . '"', 1319550405);
1137  }
1138  // Check if user is allowed to copy
1139  if (!$file->getStorage()->checkFileActionPermission('copy', $file)) {
1140  throw new InsufficientFileReadPermissionsException('You are not allowed to copy the file "' . $file->getIdentifier() . '"', 1319550426);
1141  }
1142  // Check if targetFolder is writable
1143  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1144  throw new InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetFolder->getIdentifier() . '"', 1319550435);
1145  }
1146  // Check for a valid file extension
1147  if (!$this->‪checkFileExtensionPermission($targetFileName) || !$this->‪checkFileExtensionPermission($file->getName())) {
1148  throw new IllegalFileExtensionException('You are not allowed to copy a file of that type.', 1319553317);
1149  }
1150  }
1151 
1166  protected function ‪assureFolderCopyPermissions(FolderInterface $folderToCopy, FolderInterface $targetParentFolder)
1167  {
1168  // Check if targetFolder is within this storage, this should never happen
1169  if ($this->‪getUid() !== $targetParentFolder->getStorage()->getUid()) {
1170  throw new Exception('The operation of the folder cannot be called by this storage "' . $this->‪getUid() . '"', 1377777624);
1171  }
1172  if (!$folderToCopy instanceof Folder) {
1173  throw new \RuntimeException('The folder "' . $folderToCopy->getIdentifier() . '" to copy is not of type folder.', 1384209020);
1174  }
1175  // Check if user is allowed to copy and the folder is readable
1176  if (!$folderToCopy->getStorage()->checkFolderActionPermission('copy', $folderToCopy)) {
1177  throw new InsufficientFileReadPermissionsException('You are not allowed to copy the folder "' . $folderToCopy->getIdentifier() . '"', 1377777629);
1178  }
1179  if (!$targetParentFolder instanceof Folder) {
1180  throw new \RuntimeException('The target folder "' . $targetParentFolder->getIdentifier() . '" is not of type folder.', 1384209021);
1181  }
1182  // Check if targetFolder is writable
1183  if (!$this->‪checkFolderActionPermission('write', $targetParentFolder)) {
1184  throw new InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetParentFolder->getIdentifier() . '"', 1377777635);
1185  }
1186  }
1187 
1202  protected function ‪assureFolderMovePermissions(FolderInterface $folderToMove, FolderInterface $targetParentFolder)
1203  {
1204  // Check if targetFolder is within this storage, this should never happen
1205  if ($this->‪getUid() !== $targetParentFolder->getStorage()->getUid()) {
1206  throw new \InvalidArgumentException('Cannot move a folder into a folder that does not belong to this storage.', 1325777289);
1207  }
1208  if (!$folderToMove instanceof Folder) {
1209  throw new \RuntimeException('The folder "' . $folderToMove->getIdentifier() . '" to move is not of type Folder.', 1384209022);
1210  }
1211  // Check if user is allowed to move and the folder is writable
1212  // In fact we would need to check if the parent folder of the folder to move is writable also
1213  // But as of now we cannot extract the parent folder from this folder
1214  if (!$folderToMove->getStorage()->checkFolderActionPermission('move', $folderToMove)) {
1215  throw new InsufficientFileReadPermissionsException('You are not allowed to copy the folder "' . $folderToMove->getIdentifier() . '"', 1377778045);
1216  }
1217  if (!$targetParentFolder instanceof Folder) {
1218  throw new \RuntimeException('The target folder "' . $targetParentFolder->getIdentifier() . '" is not of type Folder.', 1384209023);
1219  }
1220  // Check if targetFolder is writable
1221  if (!$this->‪checkFolderActionPermission('write', $targetParentFolder)) {
1222  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetParentFolder->getIdentifier() . '"', 1377778049);
1223  }
1224  }
1225 
1234  public function ‪sanitizeFileName($fileName, Folder $targetFolder = null)
1235  {
1236  $targetFolder = $targetFolder ?: $this->‪getDefaultFolder();
1237  $fileName = $this->driver->sanitizeFileName($fileName);
1238 
1239  // The file name could be changed by an event listener
1240  $fileName = $this->eventDispatcher->dispatch(
1241  new SanitizeFileNameEvent($fileName, $targetFolder, ‪$this, $this->driver)
1242  )->getFileName();
1243 
1244  return $fileName;
1245  }
1246 
1247  /********************
1248  * FILE ACTIONS
1249  ********************/
1263  public function ‪addFile($localFilePath, ‪Folder $targetFolder, $targetFileName = '', $conflictMode = ‪DuplicationBehavior::RENAME, $removeOriginal = true)
1264  {
1265  $localFilePath = ‪PathUtility::getCanonicalPath($localFilePath);
1266  // File is not available locally NOR is it an uploaded file
1267  if (!is_uploaded_file($localFilePath) && !file_exists($localFilePath)) {
1268  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552745);
1269  }
1270  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
1271  $targetFileName = $this->‪sanitizeFileName($targetFileName ?: ‪PathUtility::basename($localFilePath), $targetFolder);
1272 
1273  $targetFileName = $this->eventDispatcher->dispatch(
1274  new ‪BeforeFileAddedEvent($targetFileName, $localFilePath, $targetFolder, ‪$this, $this->driver)
1275  )->getFileName();
1276 
1277  $this->‪assureFileAddPermissions($targetFolder, $targetFileName);
1278 
1279  $replaceExisting = false;
1280  if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && ‪$this->driver->fileExistsInFolder($targetFileName, $targetFolder->‪getIdentifier())) {
1281  throw new ‪ExistingTargetFileNameException('File "' . $targetFileName . '" already exists in folder ' . $targetFolder->‪getIdentifier(), 1322121068);
1282  }
1283  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
1284  $targetFileName = $this->‪getUniqueName($targetFolder, $targetFileName);
1285  } elseif ($conflictMode->equals(‪DuplicationBehavior::REPLACE) && ‪$this->driver->fileExistsInFolder($targetFileName, $targetFolder->‪getIdentifier())) {
1286  $replaceExisting = true;
1287  }
1288 
1289  $fileIdentifier = $this->driver->addFile($localFilePath, $targetFolder->‪getIdentifier(), $targetFileName, $removeOriginal);
1290  $file = $this->‪getResourceFactoryInstance()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $fileIdentifier);
1291 
1292  if ($replaceExisting && $file instanceof ‪File) {
1293  $this->‪getIndexer()->‪updateIndexEntry($file);
1294  }
1295 
1296  $this->eventDispatcher->dispatch(
1297  new ‪AfterFileAddedEvent($file, $targetFolder)
1298  );
1299  return $file;
1300  }
1301 
1312  public function ‪updateProcessedFile($localFilePath, ‪ProcessedFile $processedFile, ‪Folder ‪$processingFolder = null)
1313  {
1314  if (!file_exists($localFilePath)) {
1315  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552746);
1316  }
1317  if (‪$processingFolder === null) {
1319  }
1320  $fileIdentifier = $this->driver->addFile($localFilePath, ‪$processingFolder->‪getIdentifier(), $processedFile->‪getName());
1321  // @todo check if we have to update the processed file other then the identifier
1322  $processedFile->‪setIdentifier($fileIdentifier);
1323  return $processedFile;
1324  }
1325 
1334  public function ‪hashFile(‪FileInterface $fileObject, $hash)
1335  {
1336  return $this->‪hashFileByIdentifier($fileObject->‪getIdentifier(), $hash);
1337  }
1338 
1347  public function ‪hashFileByIdentifier($fileIdentifier, $hash)
1348  {
1349  $hash = $this->driver->hash($fileIdentifier, $hash);
1350  if (!is_string($hash) || $hash === '') {
1351  throw new ‪InvalidHashException('Hash has to be non-empty string.', 1551950301);
1352  }
1353  return $hash;
1354  }
1355 
1364  public function ‪hashFileIdentifier($file)
1365  {
1366  if (is_object($file) && $file instanceof FileInterface) {
1368  $file = $file->getIdentifier();
1369  }
1370  return $this->driver->hashIdentifier($file);
1371  }
1372 
1383  public function ‪getPublicUrl(ResourceInterface $resourceObject, $relativeToCurrentScript = false)
1384  {
1385  $publicUrl = null;
1386  if ($this->‪isOnline()) {
1387  // Pre-process the public URL by an accordant event
1388  $event = new GeneratePublicUrlForResourceEvent($resourceObject, ‪$this, $this->driver, $relativeToCurrentScript);
1389  $publicUrl = $this->eventDispatcher->dispatch($event)->getPublicUrl();
1390  if (
1391  $publicUrl === null
1392  && $resourceObject instanceof File
1393  && ($helper = ‪OnlineMediaHelperRegistry::getInstance()->getOnlineMediaHelper($resourceObject)) !== false
1394  ) {
1395  $publicUrl = $helper->getPublicUrl($resourceObject, $relativeToCurrentScript);
1396  }
1397 
1398  // If an event listener did not handle the URL generation, use the default way to determine public URL
1399  if ($publicUrl === null) {
1400  if ($this->‪hasCapability(self::CAPABILITY_PUBLIC)) {
1401  $publicUrl = $this->driver->getPublicUrl($resourceObject->getIdentifier());
1402  }
1403 
1404  if ($publicUrl === null && $resourceObject instanceof FileInterface) {
1405  $queryParameterArray = ['eID' => 'dumpFile', 't' => ''];
1406  if ($resourceObject instanceof File) {
1407  $queryParameterArray['f'] = $resourceObject->getUid();
1408  $queryParameterArray['t'] = 'f';
1409  } elseif ($resourceObject instanceof ProcessedFile) {
1410  $queryParameterArray['p'] = $resourceObject->getUid();
1411  $queryParameterArray['t'] = 'p';
1412  }
1413 
1414  $queryParameterArray['token'] = GeneralUtility::hmac(implode('|', $queryParameterArray), 'resourceStorageDumpFile');
1415  $publicUrl = GeneralUtility::locationHeaderUrl(‪PathUtility::getAbsoluteWebPath(‪Environment::getPublicPath() . '/index.php'));
1416  $publicUrl .= '?' . http_build_query($queryParameterArray, '', '&', PHP_QUERY_RFC3986);
1417  }
1418 
1419  // If requested, make the path relative to the current script in order to make it possible
1420  // to use the relative file
1421  if ($publicUrl !== null && $relativeToCurrentScript && !‪GeneralUtility::isValidUrl($publicUrl)) {
1422  $absolutePathToContainingFolder = ‪PathUtility::dirname(‪Environment::getPublicPath() . '/' . $publicUrl);
1423  $pathPart = ‪PathUtility::getRelativePathTo($absolutePathToContainingFolder);
1424  $filePart = substr(‪Environment::getPublicPath() . '/' . $publicUrl, strlen($absolutePathToContainingFolder) + 1);
1425  $publicUrl = $pathPart . $filePart;
1426  }
1427  }
1428  }
1429  return $publicUrl;
1430  }
1431 
1442  public function ‪processFile(FileInterface $fileObject, $context, array ‪$configuration)
1443  {
1444  if ($fileObject->getStorage() !== ‪$this) {
1445  throw new \InvalidArgumentException('Cannot process files of foreign storage', 1353401835);
1446  }
1447  $processedFile = $this->‪getFileProcessingService()->‪processFile($fileObject, ‪$this, $context, ‪$configuration);
1448 
1449  return $processedFile;
1450  }
1451 
1459  public function ‪getFileForLocalProcessing(FileInterface $fileObject, $writable = true)
1460  {
1461  $filePath = $this->driver->getFileForLocalProcessing($fileObject->getIdentifier(), $writable);
1462  return $filePath;
1463  }
1464 
1471  public function ‪getFile($identifier)
1472  {
1473  $file = $this->‪getFileFactory()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $identifier);
1474  if (!$this->driver->fileExists($identifier)) {
1475  $file->‪setMissing(true);
1476  }
1477  return $file;
1478  }
1479 
1487  public function ‪getFileInfo(FileInterface $fileObject)
1488  {
1489  return $this->‪getFileInfoByIdentifier($fileObject->getIdentifier());
1490  }
1491 
1500  public function ‪getFileInfoByIdentifier($identifier, array $propertiesToExtract = [])
1501  {
1502  return $this->driver->getFileInfoByIdentifier($identifier, $propertiesToExtract);
1503  }
1504 
1508  public function ‪unsetFileAndFolderNameFilters()
1509  {
1510  $this->‪fileAndFolderNameFilters = [];
1511  }
1512 
1517  {
1518  $this->‪fileAndFolderNameFilters = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['defaultFilterCallbacks'];
1519  }
1520 
1527  public function getImportExportFilter(): array
1528  {
1529  $filter = GeneralUtility::makeInstance(ImportExportFilter::class);
1530 
1531  return [$filter, 'filterImportExportFilesAndFolders'];
1532  }
1533 
1539  public function getFileAndFolderNameFilters()
1540  {
1541  return array_merge($this->‪fileAndFolderNameFilters, [$this->getImportExportFilter()]);
1542  }
1548  public function setFileAndFolderNameFilters(array $filters)
1549  {
1550  $this->‪fileAndFolderNameFilters = $filters;
1551  return ‪$this;
1552  }
1557  public function ‪addFileAndFolderNameFilter($filter)
1558  {
1559  $this->‪fileAndFolderNameFilters[] = $filter;
1560  }
1561 
1567  public function ‪getFolderIdentifierFromFileIdentifier($fileIdentifier)
1568  {
1569  return $this->driver->getParentFolderIdentifierOfIdentifier($fileIdentifier);
1570  }
1571 
1579  public function ‪getFileInFolder($fileName, Folder $folder)
1580  {
1581  $identifier = $this->driver->getFileInFolder($fileName, $folder->getIdentifier());
1582  return $this->‪getFileFactory()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $identifier);
1583  }
1584 
1600  public function ‪getFilesInFolder(Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
1601  {
1602  $this->‪assureFolderReadPermission($folder);
1603 
1604  $rows = $this->‪getFileIndexRepository()->‪findByFolder($folder);
1605 
1606  $filters = $useFilters == true ? $this->getFileAndFolderNameFilters() : [];
1607  $fileIdentifiers = array_values($this->driver->getFilesInFolder($folder->getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev));
1608 
1609  $items = [];
1610  foreach ($fileIdentifiers as $identifier) {
1611  if (isset($rows[$identifier])) {
1612  $fileObject = $this->‪getFileFactory()->‪getFileObject($rows[$identifier]['uid'], $rows[$identifier]);
1613  } else {
1614  $fileObject = $this->‪getFileFactory()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $identifier);
1615  }
1616  if ($fileObject instanceof FileInterface) {
1617  $key = $fileObject->‪getName();
1618  while (isset($items[$key])) {
1619  $key .= 'z';
1620  }
1621  $items[$key] = $fileObject;
1622  }
1623  }
1624 
1625  return $items;
1626  }
1627 
1634  public function ‪getFileIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
1635  {
1636  $filters = $useFilters == true ? $this->getFileAndFolderNameFilters() : [];
1637  return $this->driver->getFilesInFolder($folderIdentifier, 0, 0, $recursive, $filters);
1638  }
1639 
1647  public function ‪countFilesInFolder(Folder $folder, $useFilters = true, $recursive = false)
1648  {
1649  $this->‪assureFolderReadPermission($folder);
1650  $filters = $useFilters ? $this->getFileAndFolderNameFilters() : [];
1651  return $this->driver->countFilesInFolder($folder->getIdentifier(), $recursive, $filters);
1652  }
1653 
1660  public function ‪getFolderIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
1661  {
1662  $filters = $useFilters == true ? $this->getFileAndFolderNameFilters() : [];
1663  return $this->driver->getFoldersInFolder($folderIdentifier, 0, 0, $recursive, $filters);
1664  }
1665 
1672  public function ‪hasFile($identifier)
1673  {
1674  // Allow if identifier is in processing folder
1675  if (!$this->‪isWithinProcessingFolder($identifier)) {
1677  }
1678  return $this->driver->fileExists($identifier);
1679  }
1680 
1686  public function ‪getProcessingFolders()
1687  {
1688  if ($this->processingFolders === null) {
1689  $this->processingFolders = [];
1690  $this->processingFolders[] = $this->‪getProcessingFolder();
1692  $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
1693  $allStorages = $storageRepository->findAll();
1694  foreach ($allStorages as $storage) {
1695  // To circumvent the permission check of the folder, we use the factory to create it "manually" instead of directly using $storage->getProcessingFolder()
1696  // See #66695 for details
1697  [$storageUid, $processingFolderIdentifier] = array_pad(‪GeneralUtility::trimExplode(':', $storage->getStorageRecord()['processingfolder']), 2, null);
1698  if (empty($processingFolderIdentifier) || (int)$storageUid !== $this->‪getUid()) {
1699  continue;
1700  }
1701  $potentialProcessingFolder = $this->‪getResourceFactoryInstance()->‪createFolderObject(‪$this, $processingFolderIdentifier, $processingFolderIdentifier);
1702  if ($potentialProcessingFolder->getStorage() === ‪$this && $potentialProcessingFolder->getIdentifier() !== ‪$this->getProcessingFolder()->getIdentifier()) {
1703  $this->processingFolders[] = $potentialProcessingFolder;
1704  }
1705  }
1706  }
1707 
1709  }
1710 
1718  public function ‪isProcessingFolder(Folder $folder)
1719  {
1720  $isProcessingFolder = false;
1721  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
1722  if ($folder->getCombinedIdentifier() === ‪$processingFolder->‪getCombinedIdentifier()) {
1723  $isProcessingFolder = true;
1724  break;
1725  }
1726  }
1727  return $isProcessingFolder;
1728  }
1729 
1737  public function ‪hasFileInFolder($fileName, ‪Folder $folder)
1738  {
1739  $this->‪assureFolderReadPermission($folder);
1740  return $this->driver->fileExistsInFolder($fileName, $folder->‪getIdentifier());
1741  }
1742 
1751  public function ‪getFileContents($file)
1752  {
1753  $this->‪assureFileReadPermission($file);
1754  return $this->driver->getFileContents($file->getIdentifier());
1755  }
1756 
1766  public function ‪streamFile(
1767  ‪FileInterface $file,
1768  bool $asDownload = false,
1769  string $alternativeFilename = null,
1770  string $overrideMimeType = null
1771  ): ResponseInterface {
1772  if (!$this->driver instanceof ‪StreamableDriverInterface) {
1773  return $this->‪getPseudoStream($file, $asDownload, $alternativeFilename, $overrideMimeType);
1774  }
1775 
1776  $properties = [
1777  'as_download' => $asDownload,
1778  'filename_overwrite' => $alternativeFilename,
1779  'mimetype_overwrite' => $overrideMimeType,
1780  ];
1781  return $this->driver->streamFile($file->‪getIdentifier(), $properties);
1782  }
1783 
1793  protected function ‪getPseudoStream(
1794  ‪FileInterface $file,
1795  bool $asDownload = false,
1796  string $alternativeFilename = null,
1797  string $overrideMimeType = null
1798  ) {
1799  $downloadName = $alternativeFilename ?: $file->‪getName();
1800  $contentDisposition = $asDownload ? 'attachment' : 'inline';
1801 
1802  $stream = new ‪FalDumpFileContentsDecoratorStream($file->‪getIdentifier(), ‪$this->driver, $file->‪getSize());
1803  $headers = [
1804  'Content-Disposition' => $contentDisposition . '; filename="' . $downloadName . '"',
1805  'Content-Type' => $overrideMimeType ?: $file->‪getMimeType(),
1806  'Content-Length' => (string)$file->‪getSize(),
1807  'Last-Modified' => gmdate('D, d M Y H:i:s', array_pop($this->driver->getFileInfoByIdentifier($file->‪getIdentifier(), ['mtime']))) . ' GMT',
1808  // Cache-Control header is needed here to solve an issue with browser IE8 and lower
1809  // See for more information: http://support.microsoft.com/kb/323308
1810  'Cache-Control' => '',
1811  ];
1812 
1813  return new ‪Response($stream, 200, $headers);
1814  }
1815 
1827  public function ‪setFileContents(‪AbstractFile $file, $contents)
1828  {
1829  // Check if user is allowed to edit
1830  $this->‪assureFileWritePermissions($file);
1831  $this->eventDispatcher->dispatch(
1832  new ‪BeforeFileContentsSetEvent($file, $contents)
1833  );
1834  // Call driver method to update the file and update file index entry afterwards
1835  $result = $this->driver->setFileContents($file->‪getIdentifier(), $contents);
1836  if ($file instanceof ‪File) {
1837  $this->‪getIndexer()->‪updateIndexEntry($file);
1838  }
1839  $this->eventDispatcher->dispatch(
1840  new AfterFileContentsSetEvent($file, $contents)
1841  );
1842  return $result;
1843  }
1844 
1857  public function ‪createFile($fileName, ‪Folder $targetFolderObject)
1858  {
1859  $this->‪assureFileAddPermissions($targetFolderObject, $fileName);
1860  $this->eventDispatcher->dispatch(
1861  new ‪BeforeFileCreatedEvent($fileName, $targetFolderObject)
1862  );
1863  $newFileIdentifier = $this->driver->createFile($fileName, $targetFolderObject->‪getIdentifier());
1864  $this->eventDispatcher->dispatch(
1865  new ‪AfterFileCreatedEvent($newFileIdentifier, $targetFolderObject)
1866  );
1867  return $this->‪getResourceFactoryInstance()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $newFileIdentifier);
1868  }
1869 
1878  public function ‪deleteFile($fileObject)
1879  {
1880  $this->‪assureFileDeletePermissions($fileObject);
1881 
1882  $this->eventDispatcher->dispatch(
1883  new ‪BeforeFileDeletedEvent($fileObject)
1884  );
1885  $deleted = true;
1886 
1887  if ($this->driver->fileExists($fileObject->getIdentifier())) {
1888  // Disable permission check to find nearest recycler and move file without errors
1889  $currentPermissions = ‪$this->evaluatePermissions;
1890  $this->evaluatePermissions = false;
1891 
1892  $recyclerFolder = $this->‪getNearestRecyclerFolder($fileObject);
1893  if ($recyclerFolder === null) {
1894  $result = $this->driver->deleteFile($fileObject->getIdentifier());
1895  } else {
1896  $result = $this->‪moveFile($fileObject, $recyclerFolder);
1897  $deleted = false;
1898  }
1899 
1900  $this->evaluatePermissions = $currentPermissions;
1901 
1902  if (!$result) {
1903  throw new ‪FileOperationErrorException('Deleting the file "' . $fileObject->getIdentifier() . '\' failed.', 1329831691);
1904  }
1905  }
1906  // Mark the file object as deleted
1907  if ($deleted && $fileObject instanceof AbstractFile) {
1908  $fileObject->setDeleted();
1909  }
1910 
1911  $this->eventDispatcher->dispatch(
1912  new AfterFileDeletedEvent($fileObject)
1913  );
1914 
1915  return true;
1916  }
1917 
1932  public function copyFile(FileInterface $file, Folder $targetFolder, $targetFileName = null, $conflictMode = DuplicationBehavior::RENAME)
1933  {
1934  $conflictMode = DuplicationBehavior::cast($conflictMode);
1935  if ($targetFileName === null) {
1936  $targetFileName = $file->getName();
1937  }
1938  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
1939  $this->assureFileCopyPermissions($file, $targetFolder, $sanitizedTargetFileName);
1940 
1941  $this->eventDispatcher->dispatch(
1942  new BeforeFileCopiedEvent($file, $targetFolder)
1943  );
1944 
1945  // File exists and we should abort, let's abort
1946  ‪if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && $targetFolder->hasFile($sanitizedTargetFileName)) {
1947  throw new ExistingTargetFileNameException('The target file already exists.', 1320291064);
1948  }
1949  // File exists and we should find another name, let's find another one
1950  ‪if ($conflictMode->equals(‪DuplicationBehavior::RENAME) && $targetFolder->hasFile($sanitizedTargetFileName)) {
1951  $sanitizedTargetFileName = $this->getUniqueName($targetFolder, $sanitizedTargetFileName);
1952  }
1953  $sourceStorage = $file->‪getStorage();
1954  // Call driver method to create a new file from an existing file object,
1955  // and return the new file object
1956  ‪if ($sourceStorage === ‪$this) {
1957  $newFileObjectIdentifier = $this->driver->copyFileWithinStorage($file->‪getIdentifier(), $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1958  } else {
1959  $tempPath = $file->‪getForLocalProcessing();
1960  $newFileObjectIdentifier = $this->driver->addFile($tempPath, $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1961  }
1962  $newFileObject = $this->‪getResourceFactoryInstance()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $newFileObjectIdentifier);
1963 
1964  $this->eventDispatcher->dispatch(
1965  new ‪AfterFileCopiedEvent($file, $targetFolder, $newFileObjectIdentifier, $newFileObject)
1966  );
1967  return $newFileObject;
1968  }
1969 
1985  public function ‪moveFile($file, $targetFolder, $targetFileName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
1986  {
1987  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
1988  if ($targetFileName === null) {
1989  $targetFileName = $file->‪getName();
1990  }
1991  $originalFolder = $file->‪getParentFolder();
1992  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
1993  $this->‪assureFileMovePermissions($file, $targetFolder, $sanitizedTargetFileName);
1994  if ($targetFolder->hasFile($sanitizedTargetFileName)) {
1995  // File exists and we should abort, let's abort
1996  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
1997  $sanitizedTargetFileName = $this->‪getUniqueName($targetFolder, $sanitizedTargetFileName);
1998  } elseif ($conflictMode->equals(‪DuplicationBehavior::CANCEL)) {
1999  throw new ‪ExistingTargetFileNameException('The target file already exists', 1329850997);
2000  }
2001  }
2002  $this->eventDispatcher->dispatch(
2003  new ‪BeforeFileMovedEvent($file, $targetFolder, $sanitizedTargetFileName)
2004  );
2005  $sourceStorage = $file->‪getStorage();
2006  // Call driver method to move the file and update the index entry
2007  try {
2008  if ($sourceStorage === ‪$this) {
2009  $newIdentifier = $this->driver->moveFileWithinStorage($file->‪getIdentifier(), $targetFolder->getIdentifier(), $sanitizedTargetFileName);
2010  if (!$file instanceof ‪AbstractFile) {
2011  throw new \RuntimeException('The given file is not of type AbstractFile.', 1384209025);
2012  }
2013  $file->‪updateProperties(['identifier' => $newIdentifier]);
2014  } else {
2015  $tempPath = $file->‪getForLocalProcessing();
2016  $newIdentifier = $this->driver->addFile($tempPath, $targetFolder->getIdentifier(), $sanitizedTargetFileName);
2017 
2018  // Disable permission check to find nearest recycler and move file without errors
2019  $currentPermissions = $sourceStorage->evaluatePermissions;
2020  $sourceStorage->evaluatePermissions = false;
2021 
2022  $recyclerFolder = $sourceStorage->getNearestRecyclerFolder($file);
2023  if ($recyclerFolder === null) {
2024  $sourceStorage->driver->deleteFile($file->‪getIdentifier());
2025  } else {
2026  $sourceStorage->moveFile($file, $recyclerFolder);
2027  }
2028  $sourceStorage->evaluatePermissions = $currentPermissions;
2029  if ($file instanceof ‪File) {
2030  $file->‪updateProperties(['storage' => $this->‪getUid(), 'identifier' => $newIdentifier]);
2031  }
2032  }
2033  $this->‪getIndexer()->‪updateIndexEntry($file);
2034  } catch (\‪TYPO3\CMS\Core\‪Exception $e) {
2035  echo $e->getMessage();
2036  }
2037  $this->eventDispatcher->dispatch(
2038  new ‪AfterFileMovedEvent($file, $targetFolder, $originalFolder)
2039  );
2040  return $file;
2041  }
2042 
2052  public function ‪renameFile($file, $targetFileName, $conflictMode = ‪DuplicationBehavior::RENAME)
2053  {
2054  // The name should be different from the current.
2055  if ($file->‪getName() === $targetFileName) {
2056  return $file;
2057  }
2058  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
2059  $this->‪assureFileRenamePermissions($file, $sanitizedTargetFileName);
2060  $this->eventDispatcher->dispatch(
2061  new BeforeFileRenamedEvent($file, $sanitizedTargetFileName)
2062  );
2063 
2064  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2065 
2066  // Call driver method to rename the file and update the index entry
2067  try {
2068  $newIdentifier = $this->driver->renameFile($file->‪getIdentifier(), $sanitizedTargetFileName);
2069  if ($file instanceof File) {
2070  $file->‪updateProperties(['identifier' => $newIdentifier]);
2071  }
2072  $this->‪getIndexer()->‪updateIndexEntry($file);
2073  } catch (ExistingTargetFileNameException $exception) {
2074  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
2075  $newName = $this->‪getUniqueName($file->‪getParentFolder(), $sanitizedTargetFileName);
2076  $file = $this->‪renameFile($file, $newName);
2077  } elseif ($conflictMode->equals(‪DuplicationBehavior::CANCEL)) {
2078  throw $exception;
2079  } elseif ($conflictMode->equals(‪DuplicationBehavior::REPLACE)) {
2080  $sourceFileIdentifier = substr($file->‪getCombinedIdentifier(), 0, (int)strrpos($file->‪getCombinedIdentifier(), '/') + 1) . $sanitizedTargetFileName;
2081  $sourceFile = $this->‪getResourceFactoryInstance()->‪getFileObjectFromCombinedIdentifier($sourceFileIdentifier);
2082  $file = $this->‪replaceFile($sourceFile, ‪Environment::getPublicPath() . '/' . $file->‪getPublicUrl());
2083  }
2084  } catch (\RuntimeException $e) {
2085  }
2086 
2087  $this->eventDispatcher->dispatch(
2088  new AfterFileRenamedEvent($file, $sanitizedTargetFileName)
2089  );
2090 
2091  return $file;
2092  }
2093 
2105  public function ‪replaceFile(‪FileInterface $file, $localFilePath)
2106  {
2107  $this->‪assureFileReplacePermissions($file);
2108  if (!file_exists($localFilePath)) {
2109  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1325842622);
2110  }
2111  $this->eventDispatcher->dispatch(
2112  new BeforeFileReplacedEvent($file, $localFilePath)
2113  );
2114  $this->driver->replaceFile($file->‪getIdentifier(), $localFilePath);
2115  if ($file instanceof File) {
2116  $this->‪getIndexer()->‪updateIndexEntry($file);
2117  }
2118  $this->eventDispatcher->dispatch(
2119  new ‪AfterFileReplacedEvent($file, $localFilePath)
2120  );
2121  return $file;
2122  }
2123 
2133  public function ‪addUploadedFile(array $uploadedFileData, ‪Folder $targetFolder = null, $targetFileName = null, $conflictMode = ‪DuplicationBehavior::CANCEL)
2134  {
2135  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2136  $localFilePath = $uploadedFileData['tmp_name'];
2137  if ($targetFolder === null) {
2138  $targetFolder = $this->‪getDefaultFolder();
2139  }
2140  if ($targetFileName === null) {
2141  $targetFileName = $uploadedFileData['name'];
2142  }
2143  $targetFileName = $this->driver->sanitizeFileName($targetFileName);
2144 
2145  $this->‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileData['size']);
2146  if ($this->‪hasFileInFolder($targetFileName, $targetFolder) && $conflictMode->equals(‪DuplicationBehavior::REPLACE)) {
2147  $file = $this->‪getFileInFolder($targetFileName, $targetFolder);
2148  $resultObject = $this->‪replaceFile($file, $localFilePath);
2149  } else {
2150  $resultObject = $this->‪addFile($localFilePath, $targetFolder, $targetFileName, (string)$conflictMode);
2151  }
2152  return $resultObject;
2153  }
2154 
2155  /********************
2156  * FOLDER ACTIONS
2157  ********************/
2164  protected function ‪getAllFileObjectsInFolder(Folder $folder)
2165  {
2166  $files = [];
2167  $folderQueue = [$folder];
2168  while (!empty($folderQueue)) {
2169  $folder = array_shift($folderQueue);
2170  foreach ($folder->getSubfolders() as $subfolder) {
2171  $folderQueue[] = $subfolder;
2172  }
2173  foreach ($folder->getFiles() as $file) {
2175  $files[$file->getIdentifier()] = $file;
2176  }
2177  }
2178 
2179  return $files;
2180  }
2181 
2196  public function ‪moveFolder(Folder $folderToMove, Folder $targetParentFolder, $newFolderName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2197  {
2198  // @todo add tests
2199  $originalFolder = $folderToMove->‪getParentFolder();
2200  $this->‪assureFolderMovePermissions($folderToMove, $targetParentFolder);
2201  $sourceStorage = $folderToMove->getStorage();
2202  $returnObject = null;
2203  $sanitizedNewFolderName = $this->driver->sanitizeFileName($newFolderName ?: $folderToMove->getName());
2204  // @todo check if folder already exists in $targetParentFolder, handle this conflict then
2205  $this->eventDispatcher->dispatch(
2206  new BeforeFolderMovedEvent($folderToMove, $targetParentFolder, $sanitizedNewFolderName)
2207  );
2208  // Get all file objects now so we are able to update them after moving the folder
2209  $fileObjects = $this->‪getAllFileObjectsInFolder($folderToMove);
2210  if ($sourceStorage === ‪$this) {
2211  if ($this->‪isWithinFolder($folderToMove, $targetParentFolder)) {
2212  throw new InvalidTargetFolderException(
2213  sprintf(
2214  'Cannot move folder "%s" into target folder "%s", because the target folder is already within the folder to be moved!',
2215  $folderToMove->getName(),
2216  $targetParentFolder->getName()
2217  ),
2218  1422723050
2219  );
2220  }
2221  $fileMappings = $this->driver->moveFolderWithinStorage($folderToMove->getIdentifier(), $targetParentFolder->getIdentifier(), $sanitizedNewFolderName);
2222  } else {
2223  $fileMappings = $this->‪moveFolderBetweenStorages($folderToMove, $targetParentFolder, $sanitizedNewFolderName);
2224  }
2225  // Update the identifier and storage of all file objects
2226  foreach ($fileObjects as $oldIdentifier => $fileObject) {
2227  $newIdentifier = $fileMappings[$oldIdentifier];
2228  $fileObject->updateProperties(['storage' => $this->‪getUid(), 'identifier' => $newIdentifier]);
2229  $this->‪getIndexer()->‪updateIndexEntry($fileObject);
2230  }
2231  $returnObject = $this->‪getFolder($fileMappings[$folderToMove->getIdentifier()]);
2232 
2233  $this->eventDispatcher->dispatch(
2234  new ‪AfterFolderMovedEvent($folderToMove, $targetParentFolder, $returnObject)
2235  );
2236  return $returnObject;
2237  }
2238 
2247  protected function ‪moveFolderBetweenStorages(‪Folder $folderToMove, ‪Folder $targetParentFolder, $newFolderName)
2248  {
2249  throw new ‪NotImplementedMethodException('Not yet implemented', 1476046361);
2250  }
2251 
2262  public function ‪copyFolder(‪FolderInterface $folderToCopy, ‪FolderInterface $targetParentFolder, $newFolderName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2263  {
2264  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2265  $this->‪assureFolderCopyPermissions($folderToCopy, $targetParentFolder);
2266  $returnObject = null;
2267  $sanitizedNewFolderName = $this->driver->sanitizeFileName($newFolderName ?: $folderToCopy->‪getName());
2268  if ($folderToCopy instanceof ‪Folder && $targetParentFolder instanceof ‪Folder) {
2269  $this->eventDispatcher->dispatch(
2270  new ‪BeforeFolderCopiedEvent($folderToCopy, $targetParentFolder, $sanitizedNewFolderName)
2271  );
2272  }
2273  if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && ($targetParentFolder->‪hasFolder($sanitizedNewFolderName) || $targetParentFolder->‪hasFile($sanitizedNewFolderName))) {
2274  throw new InvalidTargetFolderException(
2275  sprintf(
2276  'Cannot copy folder "%s" into target folder "%s", because there is already a folder or file with that name in the target folder!',
2277  $sanitizedNewFolderName,
2278  $targetParentFolder->‪getIdentifier()
2279  ),
2280  1422723059
2281  );
2282  }
2283  // Folder exists and we should find another name, let's find another one
2284  if ($conflictMode->equals(‪DuplicationBehavior::RENAME) && ($targetParentFolder->‪hasFolder($sanitizedNewFolderName) || $targetParentFolder->‪hasFile($sanitizedNewFolderName))) {
2285  $sanitizedNewFolderName = $this->‪getUniqueName($targetParentFolder, $sanitizedNewFolderName);
2286  }
2287  $sourceStorage = $folderToCopy->‪getStorage();
2288  // call driver method to move the file
2289  // that also updates the file object properties
2290  if ($sourceStorage === ‪$this) {
2291  $this->driver->copyFolderWithinStorage($folderToCopy->‪getIdentifier(), $targetParentFolder->‪getIdentifier(), $sanitizedNewFolderName);
2292  $returnObject = $this->‪getFolder($targetParentFolder->‪getSubfolder($sanitizedNewFolderName)->‪getIdentifier());
2293  } else {
2294  $this->‪copyFolderBetweenStorages($folderToCopy, $targetParentFolder, $sanitizedNewFolderName);
2295  }
2296  if ($folderToCopy instanceof Folder && $targetParentFolder instanceof Folder) {
2297  $this->eventDispatcher->dispatch(
2298  new ‪AfterFolderCopiedEvent($folderToCopy, $targetParentFolder, $returnObject)
2299  );
2300  }
2301  return $returnObject;
2302  }
2303 
2312  protected function ‪copyFolderBetweenStorages(‪FolderInterface $folderToCopy, ‪FolderInterface $targetParentFolder, $newFolderName)
2313  {
2314  throw new ‪NotImplementedMethodException('Not yet implemented.', 1476046386);
2315  }
2316 
2326  public function ‪renameFolder($folderObject, $newName)
2327  {
2328 
2329  // Renaming the folder should check if the parent folder is writable
2330  // We cannot do this however because we cannot extract the parent folder from a folder currently
2331  if (!$this->‪checkFolderActionPermission('rename', $folderObject)) {
2332  throw new ‪InsufficientUserPermissionsException('You are not allowed to rename the folder "' . $folderObject->getIdentifier() . '\'', 1357811441);
2333  }
2334 
2335  $sanitizedNewName = $this->driver->sanitizeFileName($newName);
2336  $returnObject = null;
2337  if ($this->driver->folderExistsInFolder($sanitizedNewName, $folderObject->getIdentifier())) {
2338  throw new \InvalidArgumentException('The folder ' . $sanitizedNewName . ' already exists in folder ' . $folderObject->getIdentifier(), 1325418870);
2339  }
2340  $this->eventDispatcher->dispatch(
2341  new BeforeFolderRenamedEvent($folderObject, $sanitizedNewName)
2342  );
2343  $fileObjects = $this->‪getAllFileObjectsInFolder($folderObject);
2344  $fileMappings = $this->driver->renameFolder($folderObject->getIdentifier(), $sanitizedNewName);
2345  // Update the identifier of all file objects
2346  foreach ($fileObjects as $oldIdentifier => $fileObject) {
2347  $newIdentifier = $fileMappings[$oldIdentifier];
2348  $fileObject->updateProperties(['identifier' => $newIdentifier]);
2349  $this->‪getIndexer()->‪updateIndexEntry($fileObject);
2350  }
2351  $returnObject = $this->‪getFolder($fileMappings[$folderObject->getIdentifier()]);
2352 
2353  $this->eventDispatcher->dispatch(
2354  new AfterFolderRenamedEvent($returnObject)
2355  );
2356  return $returnObject;
2357  }
2358 
2371  public function ‪deleteFolder($folderObject, $deleteRecursively = false)
2372  {
2373  $isEmpty = $this->driver->isFolderEmpty($folderObject->getIdentifier());
2374  $this->‪assureFolderDeletePermission($folderObject, $deleteRecursively && !$isEmpty);
2375  if (!$isEmpty && !$deleteRecursively) {
2376  throw new \RuntimeException('Could not delete folder "' . $folderObject->getIdentifier() . '" because it is not empty.', 1325952534);
2377  }
2378 
2379  $this->eventDispatcher->dispatch(
2380  new BeforeFolderDeletedEvent($folderObject)
2381  );
2382 
2383  foreach ($this->‪getFilesInFolder($folderObject, 0, 0, false, $deleteRecursively) as $file) {
2384  $this->‪deleteFile($file);
2385  }
2386 
2387  $result = $this->driver->deleteFolder($folderObject->getIdentifier(), $deleteRecursively);
2388 
2389  $this->eventDispatcher->dispatch(
2390  new AfterFolderDeletedEvent($folderObject, $result)
2391  );
2392  return $result;
2393  }
2394 
2405  public function ‪getFolderInFolder($folderName, ‪Folder $parentFolder, $returnInaccessibleFolderObject = false)
2406  {
2407  $folderIdentifier = $this->driver->getFolderInFolder($folderName, $parentFolder->‪getIdentifier());
2408  return $this->‪getFolder($folderIdentifier, $returnInaccessibleFolderObject);
2409  }
2410 
2425  public function ‪getFoldersInFolder(Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
2426  {
2427  $filters = $useFilters == true ? $this->getFileAndFolderNameFilters() : [];
2428 
2429  $folderIdentifiers = $this->driver->getFoldersInFolder($folder->getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev);
2430 
2431  // Exclude processing folders
2432  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
2433  $processingIdentifier = ‪$processingFolder->‪getIdentifier();
2434  if (isset($folderIdentifiers[$processingIdentifier])) {
2435  unset($folderIdentifiers[$processingIdentifier]);
2436  }
2437  }
2438 
2439  $folders = [];
2440  foreach ($folderIdentifiers as $folderIdentifier) {
2441  $folders[$folderIdentifier] = $this->‪getFolder($folderIdentifier, true);
2442  }
2443  return $folders;
2444  }
2445 
2453  public function ‪countFoldersInFolder(Folder $folder, $useFilters = true, $recursive = false)
2454  {
2455  $this->‪assureFolderReadPermission($folder);
2456  $filters = $useFilters ? $this->getFileAndFolderNameFilters() : [];
2457  return $this->driver->countFoldersInFolder($folder->getIdentifier(), $recursive, $filters);
2458  }
2459 
2466  public function ‪hasFolder($identifier)
2467  {
2469  return $this->driver->folderExists($identifier);
2470  }
2471 
2479  public function ‪hasFolderInFolder($folderName, Folder $folder)
2480  {
2481  $this->‪assureFolderReadPermission($folder);
2482  return $this->driver->folderExistsInFolder($folderName, $folder->getIdentifier());
2483  }
2498  public function ‪createFolder($folderName, ‪Folder $parentFolder = null)
2499  {
2500  if ($parentFolder === null) {
2501  $parentFolder = $this->‪getRootLevelFolder();
2502  } elseif (!$this->driver->folderExists($parentFolder->getIdentifier())) {
2503  throw new \InvalidArgumentException('Parent folder "' . $parentFolder->getIdentifier() . '" does not exist.', 1325689164);
2504  }
2505  if (!$this->‪checkFolderActionPermission('add', $parentFolder)) {
2506  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to create directories in the folder "' . $parentFolder->getIdentifier() . '"', 1323059807);
2507  }
2508  if ($this->driver->folderExistsInFolder($folderName, $parentFolder->getIdentifier())) {
2509  throw new ‪ExistingTargetFolderException('Folder "' . $folderName . '" already exists.', 1423347324);
2510  }
2511 
2512  $this->eventDispatcher->dispatch(
2513  new ‪BeforeFolderAddedEvent($parentFolder, $folderName)
2514  );
2515 
2516  $newFolder = $this->‪getDriver()->‪createFolder($folderName, $parentFolder->getIdentifier(), true);
2517  $newFolder = $this->‪getFolder($newFolder);
2519  $this->eventDispatcher->dispatch(
2520  new ‪AfterFolderAddedEvent($newFolder)
2521  );
2522 
2523  return $newFolder;
2524  }
2525 
2532  public function ‪getFolderInfo(‪Folder $folder)
2533  {
2534  return $this->driver->getFolderInfoByIdentifier($folder->‪getIdentifier());
2535  }
2536 
2542  public function ‪getDefaultFolder()
2543  {
2544  return $this->‪getFolder($this->driver->getDefaultFolder());
2545  }
2546 
2555  public function ‪getFolder($identifier, $returnInaccessibleFolderObject = false)
2556  {
2557  $data = $this->driver->getFolderInfoByIdentifier($identifier);
2558  $folder = $this->‪getResourceFactoryInstance()->‪createFolderObject(‪$this, $data['identifier'] ?? null, $data['name'] ?? null);
2559 
2560  try {
2561  $this->‪assureFolderReadPermission($folder);
2562  } catch (InsufficientFolderAccessPermissionsException $e) {
2563  $folder = null;
2564  if ($returnInaccessibleFolderObject) {
2565  // if parent folder is readable return inaccessible folder object
2566  $parentPermissions = $this->driver->getPermissions($this->driver->getParentFolderIdentifierOfIdentifier($identifier));
2567  if ($parentPermissions['r']) {
2568  $folder = GeneralUtility::makeInstance(
2569  InaccessibleFolder::class,
2570  ‪$this,
2571  $data['identifier'],
2572  $data['name']
2573  );
2574  }
2575  }
2577  if ($folder === null) {
2578  throw $e;
2579  }
2580  }
2581  return $folder;
2582  }
2583 
2590  public function ‪isWithinProcessingFolder($identifier)
2591  {
2592  $inProcessingFolder = false;
2593  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
2595  $inProcessingFolder = true;
2596  break;
2597  }
2598  }
2599  return $inProcessingFolder;
2600  }
2601 
2610  public function ‪isWithinFolder(Folder $folder, ResourceInterface $resource)
2611  {
2612  if ($folder->getStorage() !== ‪$this) {
2613  throw new \InvalidArgumentException('Given folder "' . $folder->getIdentifier() . '" is not part of this storage!', 1422709241);
2614  }
2615  if ($folder->getStorage() !== $resource->getStorage()) {
2616  return false;
2617  }
2618  return $this->driver->isWithin($folder->getIdentifier(), $resource->getIdentifier());
2619  }
2620 
2629  public function ‪getRootLevelFolder($respectFileMounts = true)
2630  {
2631  if ($respectFileMounts && !empty($this->fileMounts)) {
2632  $mount = reset($this->fileMounts);
2633  return $mount['folder'];
2634  }
2635  return $this->‪getResourceFactoryInstance()->‪createFolderObject(‪$this, $this->driver->getRootLevelFolder(), '');
2636  }
2637 
2653  protected function ‪getUniqueName(FolderInterface $folder, $theFile, $dontCheckForUnique = false)
2654  {
2655  $maxNumber = 99;
2656  // Fetches info about path, name, extension of $theFile
2657  $origFileInfo = ‪PathUtility::pathinfo($theFile);
2658  // Check if the file exists and if not - return the fileName...
2659  // The destinations file
2660  $theDestFile = $origFileInfo['basename'];
2661  // If the file does NOT exist we return this fileName
2662  if ($dontCheckForUnique || (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier()) && !‪$this->driver->folderExistsInFolder($theDestFile, $folder->getIdentifier()))) {
2663  return $theDestFile;
2664  }
2665  // Well the fileName in its pure form existed. Now we try to append
2666  // numbers / unique-strings and see if we can find an available fileName
2667  // This removes _xx if appended to the file
2668  $theTempFileBody = preg_replace('/_[0-9][0-9]$/', '', $origFileInfo['filename']);
2669  $theOrigExt = $origFileInfo['extension'] ? '.' . $origFileInfo['extension'] : '';
2670  for ($a = 1; $a <= $maxNumber + 1; $a++) {
2671  // First we try to append numbers
2672  if ($a <= $maxNumber) {
2673  $insert = '_' . sprintf('%02d', $a);
2674  } else {
2675  $insert = '_' . substr(md5(‪StringUtility::getUniqueId()), 0, 6);
2676  }
2677  $theTestFile = $theTempFileBody . $insert . $theOrigExt;
2678  // The destinations file
2679  $theDestFile = $theTestFile;
2680  // If the file does NOT exist we return this fileName
2681  if (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier()) && !‪$this->driver->folderExistsInFolder($theDestFile, $folder->getIdentifier())) {
2682  return $theDestFile;
2683  }
2684  }
2685  throw new \RuntimeException('Last possible name "' . $theDestFile . '" is already taken.', 1325194291);
2686  }
2687 
2691  protected function ‪getFileFactory()
2692  {
2693  return GeneralUtility::makeInstance(ResourceFactory::class);
2694  }
2695 
2699  protected function ‪getFileIndexRepository()
2700  {
2702  }
2703 
2707  protected function ‪getFileProcessingService()
2708  {
2709  if (!$this->fileProcessingService) {
2710  $this->fileProcessingService = GeneralUtility::makeInstance(FileProcessingService::class, ‪$this, $this->driver, $this->eventDispatcher);
2711  }
2713  }
2714 
2721  public function ‪getRole(‪FolderInterface $folder)
2722  {
2723  $folderRole = ‪FolderInterface::ROLE_DEFAULT;
2724  $identifier = $folder->‪getIdentifier();
2725  if (method_exists($this->driver, 'getRole')) {
2726  $folderRole = $this->driver->getRole($folder->‪getIdentifier());
2727  }
2728  if (isset($this->fileMounts[$identifier])) {
2729  $folderRole = ‪FolderInterface::ROLE_MOUNT;
2730 
2731  if (!empty($this->fileMounts[$identifier]['read_only'])) {
2733  }
2734  if ($this->fileMounts[$identifier]['user_mount']) {
2736  }
2737  }
2738  if ($folder instanceof ‪Folder && $this->‪isProcessingFolder($folder)) {
2740  }
2741 
2742  return $folderRole;
2743  }
2744 
2752  public function ‪getProcessingFolder(File $file = null)
2753  {
2754  // If a file is given, make sure to return the processing folder of the correct storage
2755  if ($file !== null && $file->getStorage()->getUid() !== ‪$this->getUid()) {
2756  return $file->‪getStorage()->‪getProcessingFolder($file);
2757  }
2758  if (!isset($this->processingFolder)) {
2760  if (!empty($this->storageRecord['processingfolder'])) {
2761  ‪$processingFolder = $this->storageRecord['processingfolder'];
2762  }
2763  try {
2764  if (strpos(‪$processingFolder, ':') !== false) {
2765  [$storageUid, $processingFolderIdentifier] = explode(':', ‪$processingFolder, 2);
2766  $storage = $this->‪getResourceFactoryInstance()->‪getStorageObject($storageUid);
2767  if ($storage->hasFolder($processingFolderIdentifier)) {
2768  $this->processingFolder = $storage->‪getFolder($processingFolderIdentifier);
2769  } else {
2770  $rootFolder = $storage->getRootLevelFolder(false);
2771  $currentEvaluatePermissions = $storage->getEvaluatePermissions();
2772  $storage->setEvaluatePermissions(false);
2773  $this->processingFolder = $storage->‪createFolder(
2774  ltrim($processingFolderIdentifier, '/'),
2775  $rootFolder
2776  );
2777  $storage->setEvaluatePermissions($currentEvaluatePermissions);
2778  }
2779  } else {
2780  if ($this->driver->folderExists(‪$processingFolder) === false) {
2781  $rootFolder = $this->‪getRootLevelFolder(false);
2782  try {
2783  $currentEvaluatePermissions = ‪$this->evaluatePermissions;
2784  $this->evaluatePermissions = false;
2785  $this->processingFolder = $this->‪createFolder(
2786  $processingFolder,
2787  $rootFolder
2788  );
2789  $this->evaluatePermissions = $currentEvaluatePermissions;
2790  } catch (\InvalidArgumentException $e) {
2791  $this->processingFolder = GeneralUtility::makeInstance(
2792  InaccessibleFolder::class,
2793  ‪$this,
2796  );
2797  }
2798  } else {
2799  $data = $this->driver->getFolderInfoByIdentifier(‪$processingFolder);
2800  $this->processingFolder = $this->‪getResourceFactoryInstance()->‪createFolderObject(‪$this, $data['identifier'], $data['name']);
2801  }
2802  }
2803  } catch (InsufficientFolderWritePermissionsException|ResourcePermissionsUnavailableException $e) {
2804  $this->processingFolder = GeneralUtility::makeInstance(
2805  InaccessibleFolder::class,
2806  ‪$this,
2809  );
2810  }
2811  }
2812 
2814  if (!empty($file)) {
2816  }
2817  return ‪$processingFolder;
2818  }
2819 
2829  protected function ‪getNestedProcessingFolder(File $file, Folder $rootProcessingFolder)
2830  {
2831  ‪$processingFolder = $rootProcessingFolder;
2832  $nestedFolderNames = $this->‪getNamesForNestedProcessingFolder(
2833  $file->getIdentifier(),
2834  self::PROCESSING_FOLDER_LEVELS
2835  );
2836 
2837  try {
2838  foreach ($nestedFolderNames as $folderName) {
2839  if (‪$processingFolder->‪hasFolder($folderName)) {
2841  } else {
2842  $currentEvaluatePermissions = ‪$processingFolder->‪getStorage()->‪getEvaluatePermissions();
2845  ‪$processingFolder->‪getStorage()->‪setEvaluatePermissions($currentEvaluatePermissions);
2846  }
2847  }
2848  } catch (FolderDoesNotExistException $e) {
2849  }
2850 
2851  return ‪$processingFolder;
2852  }
2853 
2861  protected function ‪getNamesForNestedProcessingFolder($fileIdentifier, $levels)
2862  {
2863  $names = [];
2864  if ($levels === 0) {
2865  return $names;
2866  }
2867  $hash = md5($fileIdentifier);
2868  for ($i = 1; $i <= $levels; $i++) {
2869  $names[] = substr($hash, $i, 1);
2870  }
2871  return $names;
2872  }
2873 
2879  public function ‪getDriverType()
2880  {
2881  return $this->storageRecord['driver'];
2882  }
2889  protected function ‪getIndexer()
2890  {
2891  return GeneralUtility::makeInstance(Indexer::class, ‪$this);
2892  }
2893 
2897  public function ‪setDefault(‪$isDefault)
2898  {
2899  $this->‪isDefault = (bool)‪$isDefault;
2900  }
2901 
2905  public function ‪isDefault()
2906  {
2907  return ‪$this->isDefault;
2908  }
2914  {
2915  return GeneralUtility::makeInstance(ResourceFactory::class);
2916  }
2917 
2923  protected function ‪getBackendUser()
2924  {
2925  return ‪$GLOBALS['BE_USER'];
2926  }
2927 
2939  protected function ‪getNearestRecyclerFolder(‪FileInterface $file)
2940  {
2941  if ($file instanceof ‪ProcessedFile) {
2942  return null;
2943  }
2944  // if the storage is not browsable we cannot fetch the parent folder of the file so no recycler handling is possible
2945  if (!$this->‪isBrowsable()) {
2946  return null;
2947  }
2948 
2949  $recyclerFolder = null;
2950  $folder = $file->‪getParentFolder();
2951 
2952  do {
2953  if ($folder->getRole() === ‪FolderInterface::ROLE_RECYCLER) {
2954  break;
2955  }
2956 
2957  foreach ($folder->‪getSubfolders() as $subFolder) {
2958  if ($subFolder->getRole() === ‪FolderInterface::ROLE_RECYCLER) {
2959  $recyclerFolder = $subFolder;
2960  break;
2961  }
2962  }
2963 
2964  $parentFolder = $folder->‪getParentFolder();
2965  $isFolderLoop = $folder->‪getIdentifier() === $parentFolder->getIdentifier();
2966  $folder = $parentFolder;
2967  } while ($recyclerFolder === null && !$isFolderLoop);
2968 
2969  return $recyclerFolder;
2970  }
2971 }
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderRenamedEvent
Definition: BeforeFolderRenamedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileProcessingService
‪Service FileProcessingService getFileProcessingService()
Definition: ResourceStorage.php:2693
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileAndFolderNameFilters
‪array $fileAndFolderNameFilters
Definition: ResourceStorage.php:202
‪TYPO3\CMS\Core\Resource\FolderInterface\getSubfolders
‪Folder[] getSubfolders()
‪TYPO3\CMS\Core\Resource\Search\Result\EmptyFileSearchResult
Definition: EmptyFileSearchResult.php:24
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderDeletedEvent
Definition: BeforeFolderDeletedEvent.php:28
‪TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile
‪File getOriginalFile()
Definition: ProcessedFile.php:303
‪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\hasHierarchicalIdentifiers
‪bool hasHierarchicalIdentifiers()
Definition: ResourceStorage.php:403
‪TYPO3\CMS\Core\Resource\ResourceStorage\renameFolder
‪Folder renameFolder($folderObject, $newName)
Definition: ResourceStorage.php:2312
‪TYPO3\CMS\Core\Resource\Event\BeforeFileCopiedEvent
Definition: BeforeFileCopiedEvent.php:30
‪TYPO3\CMS\Core\Resource\FileInterface\getExtension
‪string getExtension()
‪TYPO3\CMS\Core\Resource\ResourceStorage\deleteFolder
‪bool deleteFolder($folderObject, $deleteRecursively=false)
Definition: ResourceStorage.php:2357
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository
Definition: FileIndexRepository.php:45
‪TYPO3\CMS\Core\Resource\Event\BeforeFileCreatedEvent
Definition: BeforeFileCreatedEvent.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileAndFolderNameFilter
‪addFileAndFolderNameFilter($filter)
Definition: ResourceStorage.php:1543
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\resetFileAndFolderNameFiltersToDefault
‪resetFileAndFolderNameFiltersToDefault()
Definition: ResourceStorage.php:1502
‪TYPO3\CMS\Core\Resource\ResourceStorage\countFilesInFolder
‪int countFilesInFolder(Folder $folder, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1633
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry
Definition: OnlineMediaHelperRegistry.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInfo
‪array getFileInfo(FileInterface $fileObject)
Definition: ResourceStorage.php:1473
‪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:516
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUid
‪int getUid()
Definition: ResourceStorage.php:321
‪TYPO3\CMS\Core\Resource\File\setMissing
‪setMissing($missing)
Definition: File.php:317
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:180
‪TYPO3\CMS\Core\Resource\AbstractFile\getPublicUrl
‪string null getPublicUrl($relativeToCurrentScript=false)
Definition: AbstractFile.php:559
‪TYPO3\CMS\Core\Resource\ResourceStorage\setUserPermissions
‪setUserPermissions(array $userPermissions)
Definition: ResourceStorage.php:653
‪TYPO3\CMS\Core\Resource\AbstractFile\getIdentifier
‪string getIdentifier()
Definition: AbstractFile.php:141
‪TYPO3\CMS\Core\Resource\Event\BeforeFileReplacedEvent
Definition: BeforeFileReplacedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInfoByIdentifier
‪array getFileInfoByIdentifier($identifier, array $propertiesToExtract=[])
Definition: ResourceStorage.php:1486
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface\createFolder
‪string createFolder($newFolderName, $parentFolderIdentifier='', $recursive=false)
‪TYPO3\CMS\Core\Resource\ResourceStorage\getEvaluatePermissions
‪bool getEvaluatePermissions()
Definition: ResourceStorage.php:643
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderInFolder
‪Folder InaccessibleFolder getFolderInFolder($folderName, Folder $parentFolder, $returnInaccessibleFolderObject=false)
Definition: ResourceStorage.php:2391
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\CANCEL
‪const CANCEL
Definition: DuplicationBehavior.php:46
‪TYPO3\CMS\Core\Resource\ResourceStorage\getPublicUrl
‪string null getPublicUrl(ResourceInterface $resourceObject, $relativeToCurrentScript=false)
Definition: ResourceStorage.php:1369
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileReplacePermissions
‪assureFileReplacePermissions(FileInterface $file)
Definition: ResourceStorage.php:946
‪TYPO3\CMS\Core\Resource\ResourceStorage\PROCESSING_FOLDER_LEVELS
‪const PROCESSING_FOLDER_LEVELS
Definition: ResourceStorage.php:207
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileReadPermissionsException
Definition: InsufficientFileReadPermissionsException.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDefaultFolder
‪Folder getDefaultFolder()
Definition: ResourceStorage.php:2528
‪TYPO3\CMS\Core\Resource\FileInterface
Definition: FileInterface.php:22
‪TYPO3\CMS\Core\Resource\AbstractFile\getForLocalProcessing
‪string getForLocalProcessing($writable=true)
Definition: AbstractFile.php:577
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
Definition: InsufficientFolderAccessPermissionsException.php:24
‪TYPO3\CMS\Core\Resource\AbstractFile\getName
‪string getName()
Definition: AbstractFile.php:161
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFolder
‪Folder moveFolder(Folder $folderToMove, Folder $targetParentFolder, $newFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2182
‪TYPO3\CMS\Core\Resource\Folder\getParentFolder
‪FolderInterface getParentFolder()
Definition: Folder.php:536
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFoldersInFolder
‪Folder[] getFoldersInFolder(Folder $folder, $start=0, $maxNumberOfItems=0, $useFilters=true, $recursive=false, $sort='', $sortRev=false)
Definition: ResourceStorage.php:2411
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDriverType
‪string getDriverType()
Definition: ResourceStorage.php:2865
‪TYPO3\CMS\Core\Utility\PathUtility\dirname
‪static string dirname($path)
Definition: PathUtility.php:186
‪TYPO3\CMS\Core\Resource\Security\FileNameValidator
Definition: FileNameValidator.php:25
‪TYPO3\CMS\Core\Resource\ResourceStorage\processFile
‪ProcessedFile processFile(FileInterface $fileObject, $context, array $configuration)
Definition: ResourceStorage.php:1428
‪TYPO3\CMS\Core\Resource\ResourceStorage\$storageRecord
‪array $storageRecord
Definition: ResourceStorage.php:133
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_DEFAULT
‪const ROLE_DEFAULT
Definition: FolderInterface.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileExtensionPermission
‪bool checkFileExtensionPermission($fileName)
Definition: ResourceStorage.php:839
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFilesInFolder
‪File[] getFilesInFolder(Folder $folder, $start=0, $maxNumberOfItems=0, $useFilters=true, $recursive=false, $sort='', $sortRev=false)
Definition: ResourceStorage.php:1586
‪TYPO3\CMS\Core\Resource\ResourceStorage\getStorageRecord
‪array getStorageRecord()
Definition: ResourceStorage.php:279
‪TYPO3
‪TYPO3\CMS\Core\Resource\Index\Indexer\updateIndexEntry
‪File updateIndexEntry(File $fileObject)
Definition: Indexer.php:97
‪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:2738
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileFactory
‪ResourceFactory getFileFactory()
Definition: ResourceStorage.php:2677
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileMount
‪addFileMount($folderIdentifier, $additionalData=[])
Definition: ResourceStorage.php:536
‪TYPO3\CMS\Core\Registry
Definition: Registry.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\$configuration
‪array $configuration
Definition: ResourceStorage.php:139
‪if
‪if(PHP_SAPI !=='cli')
Definition: splitAcceptanceTests.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\copyFolderBetweenStorages
‪copyFolderBetweenStorages(FolderInterface $folderToCopy, FolderInterface $targetParentFolder, $newFolderName)
Definition: ResourceStorage.php:2298
‪TYPO3\CMS\Core\Resource\Event\AfterFolderCopiedEvent
Definition: AfterFolderCopiedEvent.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\addUploadedFile
‪FileInterface addUploadedFile(array $uploadedFileData, Folder $targetFolder=null, $targetFileName=null, $conflictMode=DuplicationBehavior::CANCEL)
Definition: ResourceStorage.php:2119
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolder
‪Folder InaccessibleFolder getFolder($identifier, $returnInaccessibleFolderObject=false)
Definition: ResourceStorage.php:2541
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderIdentifierFromFileIdentifier
‪string getFolderIdentifierFromFileIdentifier($fileIdentifier)
Definition: ResourceStorage.php:1553
‪TYPO3\CMS\Core\Resource\ResourceStorage\replaceFile
‪FileInterface replaceFile(FileInterface $file, $localFilePath)
Definition: ResourceStorage.php:2091
‪TYPO3\CMS\Core\Resource\ResourceStorage\renameFile
‪FileInterface renameFile($file, $targetFileName, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2038
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface
Definition: DriverInterface.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFile
‪FileInterface getFile($identifier)
Definition: ResourceStorage.php:1457
‪TYPO3\CMS\Core\Resource\Event\BeforeFileRenamedEvent
Definition: BeforeFileRenamedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDriver
‪Driver DriverInterface getDriver()
Definition: ResourceStorage.php:301
‪TYPO3\CMS\Core\Resource\ResourceStorage\$isOnline
‪bool $isOnline
Definition: ResourceStorage.php:192
‪TYPO3\CMS\Core\Resource\Event\AfterFileCreatedEvent
Definition: AfterFileCreatedEvent.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFileByIdentifier
‪string hashFileByIdentifier($fileIdentifier, $hash)
Definition: ResourceStorage.php:1333
‪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:1536
‪TYPO3\CMS\Core\Resource\FileInterface\getSize
‪int getSize()
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
Definition: ExistingTargetFileNameException.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\DEFAULT_ProcessingFolder
‪const DEFAULT_ProcessingFolder
Definition: ResourceStorageInterface.php:183
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasCapability
‪bool hasCapability($capability)
Definition: ResourceStorage.php:359
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessingFolders
‪Folder[] getProcessingFolders()
Definition: ResourceStorage.php:1672
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileIdentifiersInFolder
‪array getFileIdentifiersInFolder($folderIdentifier, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1620
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository\findByFolder
‪array null findByFolder(Folder $folder)
Definition: FileIndexRepository.php:214
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderInfo
‪array getFolderInfo(Folder $folder)
Definition: ResourceStorage.php:2518
‪TYPO3\CMS\Core\Resource\Event\BeforeFileMovedEvent
Definition: BeforeFileMovedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceInterface\getIdentifier
‪string getIdentifier()
‪TYPO3\CMS\Core\Resource\ResourceInterface\getStorage
‪ResourceStorage getStorage()
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFolder
‪bool hasFolder($identifier)
Definition: ResourceStorage.php:2452
‪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:589
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileContents
‪string getFileContents($file)
Definition: ResourceStorage.php:1737
‪TYPO3\CMS\Core\Utility\PathUtility\getCanonicalPath
‪static string getCanonicalPath($path)
Definition: PathUtility.php:307
‪TYPO3\CMS\Core\Resource\ResourceStorage\isDefault
‪bool isDefault()
Definition: ResourceStorage.php:2891
‪TYPO3\CMS\Core\Resource\ResourceStorage\isProcessingFolder
‪bool isProcessingFolder(Folder $folder)
Definition: ResourceStorage.php:1704
‪TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException
Definition: IllegalFileExtensionException.php:24
‪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:1565
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFile
‪bool hasFile($identifier)
Definition: ResourceStorage.php:1658
‪TYPO3\CMS\Core\Utility\PathUtility\basename
‪static string basename($path)
Definition: PathUtility.php:165
‪TYPO3\CMS\Core\Resource\ResourceStorage\setFileContents
‪int setFileContents(AbstractFile $file, $contents)
Definition: ResourceStorage.php:1813
‪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:2615
‪TYPO3\CMS\Core\Resource\Event\AfterFolderRenamedEvent
Definition: AfterFolderRenamedEvent.php:28
‪TYPO3\CMS\Core\Resource\Folder\getName
‪string getName()
Definition: Folder.php:94
‪TYPO3\CMS\Core\Resource\Exception\UploadException
Definition: UploadException.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\$capabilities
‪int $capabilities
Definition: ResourceStorage.php:172
‪TYPO3\CMS\Core\Resource\FolderInterface\hasFolder
‪bool hasFolder($name)
‪TYPO3\CMS\Core\Resource\Event\GeneratePublicUrlForResourceEvent
Definition: GeneratePublicUrlForResourceEvent.php:31
‪TYPO3\CMS\Core\Utility\PathUtility\getRelativePathTo
‪static string null getRelativePathTo($targetPath)
Definition: PathUtility.php:32
‪TYPO3\CMS\Core\Resource\Folder\getStorage
‪ResourceStorage getStorage()
Definition: Folder.php:149
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFileIdentifier
‪string hashFileIdentifier($file)
Definition: ResourceStorage.php:1350
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFile
‪FileInterface addFile($localFilePath, Folder $targetFolder, $targetFileName='', $conflictMode=DuplicationBehavior::RENAME, $removeOriginal=true)
Definition: ResourceStorage.php:1249
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileReadPermission
‪assureFileReadPermission(FileInterface $file)
Definition: ResourceStorage.php:904
‪TYPO3\CMS\Core\Resource\ResourceStorage\$driver
‪Driver DriverInterface $driver
Definition: ResourceStorage.php:127
‪TYPO3\CMS\Core\Resource\ResourceStorage\isOnline
‪bool isOnline()
Definition: ResourceStorage.php:448
‪TYPO3\CMS\Core\Resource\InaccessibleFolder
Definition: InaccessibleFolder.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileAndFolderNameFilters
‪bool checkFileAndFolderNameFilters(ResourceInterface $fileOrFolder)
Definition: ResourceStorage.php:809
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFolderActionPermission
‪bool checkFolderActionPermission($action, Folder $folder=null)
Definition: ResourceStorage.php:760
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\setEvaluatePermissions
‪setEvaluatePermissions($evaluatePermissions)
Definition: ResourceStorage.php:632
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFile
‪FileInterface moveFile($file, $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:1971
‪TYPO3\CMS\Core\Resource\AbstractFile
Definition: AbstractFile.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\getRole
‪string getRole(FolderInterface $folder)
Definition: ResourceStorage.php:2707
‪TYPO3\CMS\Core\Resource\ResourceStorage\markAsPermanentlyOffline
‪markAsPermanentlyOffline()
Definition: ResourceStorage.php:494
‪TYPO3\CMS\Core\Resource\Exception\InvalidConfigurationException
Definition: InvalidConfigurationException.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\getAllFileObjectsInFolder
‪File[] getAllFileObjectsInFolder(Folder $folder)
Definition: ResourceStorage.php:2150
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileMovePermissions
‪assureFileMovePermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
Definition: ResourceStorage.php:1055
‪TYPO3\CMS\Core\Resource\Search\Result\FileSearchResult
Definition: FileSearchResult.php:31
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderAddedEvent
Definition: BeforeFolderAddedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileAddPermissions
‪assureFileAddPermissions($targetFolder, $targetFileName)
Definition: ResourceStorage.php:998
‪TYPO3\CMS\Core\Resource\ResourceStorage\__construct
‪__construct(DriverInterface $driver, array $storageRecord, EventDispatcherInterface $eventDispatcher=null)
Definition: ResourceStorage.php:216
‪TYPO3\CMS\Core\Resource\ResourceStorage\getCapabilities
‪int getCapabilities()
Definition: ResourceStorage.php:348
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface\isWithin
‪bool isWithin($folderIdentifier, $identifier)
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileForLocalProcessing
‪string getFileForLocalProcessing(FileInterface $fileObject, $writable=true)
Definition: ResourceStorage.php:1445
‪TYPO3\CMS\Core\Resource\ResourceFactory\convertFlexFormDataToConfigurationArray
‪array convertFlexFormDataToConfigurationArray($flexFormData)
Definition: ResourceFactory.php:283
‪TYPO3\CMS\Core\Resource\Folder\getSubfolders
‪Folder[] getSubfolders($start=0, $numberOfItems=0, $filterMode=self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, $recursive=false)
Definition: Folder.php:290
‪TYPO3\CMS\Core\Resource\ResourceStorage\isBrowsable
‪bool isBrowsable()
Definition: ResourceStorage.php:393
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFolder
‪Folder createFolder($folderName, Folder $parentFolder=null)
Definition: ResourceStorage.php:2484
‪TYPO3\CMS\Core\Resource\Folder\createFolder
‪Folder createFolder($folderName)
Definition: Folder.php:364
‪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\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\Index\FileIndexRepository\getInstance
‪static FileIndexRepository getInstance()
Definition: FileIndexRepository.php:78
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFile
‪FileInterface createFile($fileName, Folder $targetFolderObject)
Definition: ResourceStorage.php:1843
‪TYPO3\CMS\Core\Resource\Event\AfterFileRenamedEvent
Definition: AfterFileRenamedEvent.php:27
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinFolder
‪bool isWithinFolder(Folder $folder, ResourceInterface $resource)
Definition: ResourceStorage.php:2596
‪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\ResourceStorage\autoExtractMetadataEnabled
‪bool autoExtractMetadataEnabled()
Definition: ResourceStorage.php:482
‪TYPO3\CMS\Core\Resource\FolderInterface\getSubfolder
‪Folder getSubfolder($name)
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileDeletePermissions
‪assureFileDeletePermissions(FileInterface $file)
Definition: ResourceStorage.php:966
‪TYPO3\CMS\Core\Resource\ResourceStorage\getConfiguration
‪array getConfiguration()
Definition: ResourceStorage.php:259
‪TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: AbstractFile.php:447
‪TYPO3\CMS\Core\Resource\Event\AfterFileCopiedEvent
Definition: AfterFileCopiedEvent.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasChildren
‪bool hasChildren()
Definition: ResourceStorage.php:331
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileMounts
‪array getFileMounts()
Definition: ResourceStorage.php:576
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_PROCESSING
‪const ROLE_PROCESSING
Definition: FolderInterface.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinProcessingFolder
‪bool isWithinProcessingFolder($identifier)
Definition: ResourceStorage.php:2576
‪TYPO3\CMS\Core\Utility\PathUtility\pathinfo
‪static string string[] pathinfo($path, $options=null)
Definition: PathUtility.php:208
‪TYPO3\CMS\Core\Resource\ResourceStorage\getBackendUser
‪TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser()
Definition: ResourceStorage.php:2909
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFolderBetweenStorages
‪moveFolderBetweenStorages(Folder $folderToMove, Folder $targetParentFolder, $newFolderName)
Definition: ResourceStorage.php:2233
‪TYPO3\CMS\Core\Resource\ResourceStorage\$eventDispatcher
‪EventDispatcherInterface $eventDispatcher
Definition: ResourceStorage.php:176
‪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:218
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderCopyPermissions
‪assureFolderCopyPermissions(FolderInterface $folderToCopy, FolderInterface $targetParentFolder)
Definition: ResourceStorage.php:1152
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFileObjectFromCombinedIdentifier
‪File ProcessedFile null getFileObjectFromCombinedIdentifier($identifier)
Definition: ResourceFactory.php:415
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_MOUNT
‪const ROLE_MOUNT
Definition: FolderInterface.php:31
‪TYPO3\CMS\Core\Resource\AbstractFile\getParentFolder
‪FolderInterface getParentFolder()
Definition: AbstractFile.php:602
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileProcessingService
‪Service FileProcessingService $fileProcessingService
Definition: ResourceStorage.php:143
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNamesForNestedProcessingFolder
‪string[] getNamesForNestedProcessingFolder($fileIdentifier, $levels)
Definition: ResourceStorage.php:2847
‪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:1220
‪TYPO3\CMS\Core\Resource\Folder\getSubfolder
‪Folder getSubfolder($name)
Definition: Folder.php:273
‪TYPO3\CMS\Core\Resource\ResourceInterface\getName
‪string getName()
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_USER_MOUNT
‪const ROLE_USER_MOUNT
Definition: FolderInterface.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\$isDefault
‪bool $isDefault
Definition: ResourceStorage.php:196
‪TYPO3\CMS\Core\Resource
Definition: generateMimeTypes.php:52
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static string[] trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:1059
‪TYPO3\CMS\Core\Resource\ProcessedFile
Definition: ProcessedFile.php:44
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_BROWSABLE
‪const CAPABILITY_BROWSABLE
Definition: ResourceStorageInterface.php:166
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\getInstance
‪static OnlineMediaHelperRegistry getInstance()
Definition: OnlineMediaHelperRegistry.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\$this
‪return $this
Definition: ResourceStorage.php:1537
‪TYPO3\CMS\Core\Resource\ResourceStorage\$processingFolders
‪Folder[] $processingFolders
Definition: ResourceStorage.php:186
‪TYPO3\CMS\Core\Resource\Event\BeforeFileAddedEvent
Definition: BeforeFileAddedEvent.php:30
‪TYPO3\CMS\Core\Utility\GeneralUtility\isValidUrl
‪static bool isValidUrl($url)
Definition: GeneralUtility.php:944
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderReadPermission
‪assureFolderReadPermission(Folder $folder=null)
Definition: ResourceStorage.php:851
‪TYPO3\CMS\Core\Resource\ResourceStorage\usesCaseSensitiveIdentifiers
‪bool usesCaseSensitiveIdentifiers()
Definition: ResourceStorage.php:438
‪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:1723
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_READONLY_MOUNT
‪const ROLE_READONLY_MOUNT
Definition: FolderInterface.php:32
‪TYPO3\CMS\Core\Resource\AbstractFile\setIdentifier
‪File setIdentifier($identifier)
Definition: AbstractFile.php:435
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileCopyPermissions
‪assureFileCopyPermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
Definition: ResourceStorage.php:1118
‪TYPO3\CMS\Core\Resource\ResourceFactory\createFolderObject
‪Folder createFolderObject(ResourceStorage $storage, $identifier, $name)
Definition: ResourceFactory.php:374
‪TYPO3\CMS\Core\Resource\ResourceStorage\$evaluatePermissions
‪bool $evaluatePermissions
Definition: ResourceStorage.php:152
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:122
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:92
‪TYPO3\CMS\Core\Resource\ResourceStorage\setDriver
‪ResourceStorage setDriver(DriverInterface $driver)
Definition: ResourceStorage.php:290
‪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:1779
‪TYPO3\CMS\Core\Resource\ResourceFactory\getStorageObject
‪ResourceStorage getStorageObject($uid, array $recordData=[], &$fileIdentifier=null)
Definition: ResourceFactory.php:139
‪TYPO3\CMS\Core\Resource\ResourceStorage\searchFiles
‪FileSearchResultInterface searchFiles(FileSearchDemand $searchDemand, Folder $folder=null, bool $useFilters=true)
Definition: ResourceStorage.php:417
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderMovePermissions
‪assureFolderMovePermissions(FolderInterface $folderToMove, FolderInterface $targetParentFolder)
Definition: ResourceStorage.php:1188
‪TYPO3\CMS\Core\Resource\ResourceStorage\isPublic
‪bool isPublic()
Definition: ResourceStorage.php:372
‪TYPO3\CMS\Core\Log\LogManager
Definition: LogManager.php:30
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNearestRecyclerFolder
‪Folder null getNearestRecyclerFolder(FileInterface $file)
Definition: ResourceStorage.php:2925
‪TYPO3\CMS\Core\Resource\ResourceStorage\countFoldersInFolder
‪int countFoldersInFolder(Folder $folder, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:2439
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_RECYCLER
‪const ROLE_RECYCLER
Definition: FolderInterface.php:27
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException
Definition: InsufficientFolderWritePermissionsException.php:22
‪TYPO3\CMS\Core\Resource\FolderInterface
Definition: FolderInterface.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFile
‪string hashFile(FileInterface $fileObject, $hash)
Definition: ResourceStorage.php:1320
‪TYPO3\CMS\Core\Resource\ResourceStorage\$processingFolder
‪Folder $processingFolder
Definition: ResourceStorage.php:180
‪TYPO3\CMS\Core\Resource\ResourceStorage\streamFile
‪ResponseInterface streamFile(FileInterface $file, bool $asDownload=false, string $alternativeFilename=null, string $overrideMimeType=null)
Definition: ResourceStorage.php:1752
‪TYPO3\CMS\Core\Resource\ResourceStorage\setConfiguration
‪setConfiguration(array $configuration)
Definition: ResourceStorage.php:269
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFileObject
‪File getFileObject($uid, array $fileData=[])
Definition: ResourceFactory.php:390
‪TYPO3\CMS\Core\Resource\FolderInterface\hasFile
‪bool hasFile($name)
‪TYPO3\CMS\Core\Resource\ResourceStorage\updateProcessedFile
‪FileInterface updateProcessedFile($localFilePath, ProcessedFile $processedFile, Folder $processingFolder=null)
Definition: ResourceStorage.php:1298
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileRenamePermissions
‪assureFileRenamePermissions(FileInterface $file, $targetFileName)
Definition: ResourceStorage.php:1085
‪TYPO3\CMS\Core\Utility\Exception\NotImplementedMethodException
Definition: NotImplementedMethodException.php:27
‪TYPO3\CMS\Core\Resource\Filter\ImportExportFilter
Definition: ImportExportFilter.php:31
‪TYPO3\CMS\Core\Resource\Folder\getIdentifier
‪string getIdentifier()
Definition: Folder.php:160
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileWritePermissions
‪assureFileWritePermissions(FileInterface $file)
Definition: ResourceStorage.php:928
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\REPLACE
‪const REPLACE
Definition: DuplicationBehavior.php:39
‪TYPO3\CMS\Core\Resource\ResourceInterface
Definition: ResourceInterface.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWritable
‪bool isWritable()
Definition: ResourceStorage.php:383
‪TYPO3\CMS\Core\Resource\Folder\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: Folder.php:181
‪TYPO3\CMS\Core\Resource\ResourceStorage\$userPermissions
‪array $userPermissions
Definition: ResourceStorage.php:165
‪TYPO3\CMS\Core\Resource\Service\FileProcessingService
Definition: FileProcessingService.php:38
‪TYPO3\CMS\Core\Resource\Event\SanitizeFileNameEvent
Definition: SanitizeFileNameEvent.php:29
‪TYPO3\CMS\Core\Resource\AbstractFile\updateProperties
‪updateProperties(array $properties)
‪TYPO3\CMS\Core\Resource\ResourceStorage\getResourceFactoryInstance
‪ResourceFactory getResourceFactoryInstance()
Definition: ResourceStorage.php:2899
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Resource\ResourceStorage\unsetFileAndFolderNameFilters
‪unsetFileAndFolderNameFilters()
Definition: ResourceStorage.php:1494
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface\setStorageUid
‪setStorageUid($storageUid)
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderMovedEvent
Definition: BeforeFolderMovedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileActionPermission
‪bool checkFileActionPermission($action, FileInterface $file)
Definition: ResourceStorage.php:693
‪TYPO3\CMS\Core\Resource\FileInterface\getMimeType
‪string getMimeType()
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:43
‪TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException
Definition: FileOperationErrorException.php:22
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderIdentifiersInFolder
‪array getFolderIdentifiersInFolder($folderIdentifier, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1646
‪TYPO3\CMS\Core\Resource\Event\AfterFileReplacedEvent
Definition: AfterFileReplacedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkUserActionPermission
‪bool checkUserActionPermission($action, $type)
Definition: ResourceStorage.php:666
‪TYPO3\CMS\Core\Resource\Event\AfterFolderDeletedEvent
Definition: AfterFolderDeletedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceInterface\getParentFolder
‪FolderInterface getParentFolder()
‪TYPO3\CMS\Core\Resource\Service\FileProcessingService\processFile
‪Resource ProcessedFile processFile(FileInterface $fileObject, ResourceStorage $targetStorage, $taskType, $configuration)
Definition: FileProcessingService.php:86
‪TYPO3\CMS\Core\Resource\Event\AfterFileDeletedEvent
Definition: AfterFileDeletedEvent.php:29
‪TYPO3\CMS\Core\Resource\Driver\StreamableDriverInterface
Definition: StreamableDriverInterface.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUniqueName
‪string getUniqueName(FolderInterface $folder, $theFile, $dontCheckForUnique=false)
Definition: ResourceStorage.php:2639
‪TYPO3\CMS\Core\Resource\ResourceStorage\deleteFile
‪bool deleteFile($fileObject)
Definition: ResourceStorage.php:1864
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderDeletePermission
‪assureFolderDeletePermission(Folder $folder, $checkDeleteRecursively)
Definition: ResourceStorage.php:876
‪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:2875
‪TYPO3\CMS\Core\Resource\Folder\hasFolder
‪bool hasFolder($name)
Definition: Folder.php:412
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFolderInFolder
‪bool hasFolderInFolder($folderName, Folder $folder)
Definition: ResourceStorage.php:2465
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileIndexRepository
‪Index FileIndexRepository getFileIndexRepository()
Definition: ResourceStorage.php:2685
‪TYPO3\CMS\Core\Resource\ResourceStorage\copyFolder
‪Folder copyFolder(FolderInterface $folderToCopy, FolderInterface $targetParentFolder, $newFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2248
‪TYPO3\CMS\Core\Resource\ProcessedFile\getName
‪string getName()
Definition: ProcessedFile.php:331
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_WRITABLE
‪const CAPABILITY_WRITABLE
Definition: ResourceStorageInterface.php:175
‪TYPO3\CMS\Core\Resource\Event\AfterFileAddedEvent
Definition: AfterFileAddedEvent.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\setDefault
‪setDefault($isDefault)
Definition: ResourceStorage.php:2883
‪TYPO3\CMS\Core\Resource\ResourceStorage\getName
‪string getName()
Definition: ResourceStorage.php:311
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileMounts
‪array $fileMounts
Definition: ResourceStorage.php:158
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFileObjectByStorageAndIdentifier
‪File ProcessedFile null getFileObjectByStorageAndIdentifier($storageUid, &$fileIdentifier)
Definition: ResourceFactory.php:445
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileUploadPermissions
‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileSize)
Definition: ResourceStorage.php:1029
‪TYPO3\CMS\Core\Resource\AbstractFile\getStorage
‪ResourceStorage getStorage()
Definition: AbstractFile.php:390
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNestedProcessingFolder
‪Folder getNestedProcessingFolder(File $file, Folder $rootProcessingFolder)
Definition: ResourceStorage.php:2815