‪TYPO3CMS  ‪main
ResourceStorage.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\EventDispatcher\EventDispatcherInterface;
19 use Psr\Http\Message\ResponseInterface;
20 use Psr\Http\Message\ServerRequestInterface;
93 
127 {
133  protected ‪$driver;
134 
140  protected ‪$storageRecord;
141 
147  protected ‪$configuration;
148 
152  protected ‪$fileProcessingService;
153 
162  protected ‪$evaluatePermissions = false;
163 
169  protected ‪$fileMounts = [];
170 
177  protected ‪$userPermissions = [];
178 
185  protected ‪$capabilities;
186 
190  protected ‪$eventDispatcher;
191 
195  protected ‪$processingFolder;
196 
202  protected ‪$processingFolders;
203 
209  protected ‪$isOnline;
210 
214  protected ‪$isDefault = false;
215 
221  protected ‪$fileAndFolderNameFilters = [];
222 
226  public const ‪PROCESSING_FOLDER_LEVELS = 2;
227 
234  public function ‪__construct(‪DriverInterface ‪$driver, array ‪$storageRecord, EventDispatcherInterface ‪$eventDispatcher = null)
235  {
236  $this->storageRecord = ‪$storageRecord;
237  $this->eventDispatcher = ‪$eventDispatcher ?? GeneralUtility::makeInstance(EventDispatcherInterface::class);
238  if (is_array(‪$storageRecord['configuration'] ?? null)) {
239  $this->configuration = ‪$storageRecord['configuration'];
240  } elseif (!empty(‪$storageRecord['configuration'] ?? '')) {
241  $this->configuration = GeneralUtility::makeInstance(FlexFormService::class)->convertFlexFormContentToArray(‪$storageRecord['configuration']);
242  } else {
243  $this->configuration = [];
244  }
245  $this->capabilities =
246  ($this->storageRecord['is_browsable'] ?? null ? ‪self::CAPABILITY_BROWSABLE : 0) |
247  ($this->storageRecord['is_public'] ?? null ? self::CAPABILITY_PUBLIC : 0) |
248  ($this->storageRecord['is_writable'] ?? null ? ‪self::CAPABILITY_WRITABLE : 0) |
249  // Always let the driver decide whether to set this capability
250  self::CAPABILITY_HIERARCHICAL_IDENTIFIERS;
251 
252  $this->driver = ‪$driver;
253  $this->driver->‪setStorageUid(‪$storageRecord['uid'] ?? null);
254  $this->driver->mergeConfigurationCapabilities($this->capabilities);
255  try {
256  $this->driver->processConfiguration();
257  } catch (‪InvalidConfigurationException $e) {
258  // Configuration error
259  $this->‪isOnline = false;
260 
261  $message = sprintf(
262  'Failed initializing storage [%d] "%s", error: %s',
263  $this->‪getUid(),
264  $this->‪getName(),
265  $e->getMessage()
266  );
267 
268  // create a dedicated logger instance because we need a logger in the constructor
269  GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class)->error($message);
270  }
271  $this->driver->initialize();
272  $this->capabilities = $this->driver->getCapabilities();
273 
274  $this->‪isDefault = (isset(‪$storageRecord['is_default']) && ‪$storageRecord['is_default'] == 1);
276  }
277 
283  public function ‪getConfiguration()
284  {
286  }
287 
291  public function ‪setConfiguration(array ‪$configuration)
292  {
293  $this->configuration = ‪$configuration;
294  }
295 
301  public function ‪getStorageRecord()
302  {
304  }
305 
311  public function ‪setDriver(DriverInterface ‪$driver)
312  {
313  $this->driver = ‪$driver;
314  return ‪$this;
315  }
316 
322  protected function ‪getDriver()
323  {
324  return ‪$this->driver;
325  }
326 
332  public function ‪getName()
333  {
334  return $this->storageRecord['name'];
335  }
336 
342  public function ‪getUid()
343  {
344  return (int)($this->storageRecord['uid'] ?? 0);
345  }
346 
352  public function ‪hasChildren()
353  {
354  return true;
355  }
356 
357  /*********************************
358  * Capabilities
359  ********************************/
369  public function ‪getCapabilities()
370  {
371  return (int)‪$this->capabilities;
372  }
373 
380  protected function ‪hasCapability($capability)
381  {
382  return ($this->capabilities & $capability) == $capability;
383  }
384 
393  public function ‪isPublic()
394  {
395  return $this->‪hasCapability(self::CAPABILITY_PUBLIC);
396  }
397 
404  public function ‪isWritable()
405  {
406  return $this->‪hasCapability(self::CAPABILITY_WRITABLE);
407  }
408 
414  public function ‪isBrowsable()
415  {
416  return $this->‪isOnline() && $this->‪hasCapability(self::CAPABILITY_BROWSABLE);
417  }
418 
422  public function ‪hasHierarchicalIdentifiers(): bool
423  {
424  return $this->‪hasCapability(self::CAPABILITY_HIERARCHICAL_IDENTIFIERS);
425  }
426 
434  public function ‪searchFiles(FileSearchDemand $searchDemand, Folder $folder = null, bool $useFilters = true): FileSearchResultInterface
435  {
436  $folder = $folder ?? $this->‪getRootLevelFolder();
437  if (!$folder->‪checkActionPermission('read')) {
438  return new EmptyFileSearchResult();
439  }
440 
443  $searchDemand->withFolder($folder)
444  ),
445  ‪$this->driver,
446  $useFilters ? ‪$this->getFileAndFolderNameFilters() : []
447  );
448  }
449 
455  public function ‪usesCaseSensitiveIdentifiers()
456  {
457  return $this->driver->isCaseSensitiveFileSystem();
458  }
459 
465  public function ‪isOnline()
466  {
467  if ($this->‪isOnline === null) {
468  if ($this->‪getUid() === 0) {
469  $this->‪isOnline = true;
470  }
471  // the storage is not marked as online for a longer time
472  if ($this->storageRecord['is_online'] == 0) {
473  $this->‪isOnline = false;
474  }
475  if ($this->‪isOnline !== false) {
476  if ((‪$GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
477  && ‪ApplicationType::fromRequest(‪$GLOBALS['TYPO3_REQUEST'])->isFrontend()
478  ) {
479  // All files are ALWAYS available in the frontend
480  $this->‪isOnline = true;
481  } else {
482  // check if the storage is disabled temporary for now
483  $registryObject = GeneralUtility::makeInstance(Registry::class);
484  $offlineUntil = $registryObject->get('core', 'sys_file_storage-' . $this->‪getUid() . '-offline-until');
485  if ($offlineUntil && $offlineUntil > time()) {
486  $this->‪isOnline = false;
487  } else {
488  $this->‪isOnline = true;
489  }
490  }
491  }
492  }
493  return ‪$this->isOnline;
494  }
495 
501  public function ‪autoExtractMetadataEnabled()
502  {
503  return !empty($this->storageRecord['auto_extract_metadata']);
504  }
505 
513  public function ‪markAsPermanentlyOffline()
514  {
515  if ($this->‪getUid() > 0) {
516  // @todo: move this to the storage repository
517  GeneralUtility::makeInstance(ConnectionPool::class)
518  ->getConnectionForTable('sys_file_storage')
519  ->update(
520  'sys_file_storage',
521  ['is_online' => 0],
522  ['uid' => (int)$this->‪getUid()]
523  );
524  }
525  $this->storageRecord['is_online'] = 0;
526  $this->‪isOnline = false;
527  }
528 
535  public function ‪markAsTemporaryOffline()
536  {
537  $registryObject = GeneralUtility::makeInstance(Registry::class);
538  $registryObject->set('core', 'sys_file_storage-' . $this->‪getUid() . '-offline-until', time() + 60 * 5);
539  $this->storageRecord['is_online'] = 0;
540  $this->‪isOnline = false;
541  }
542 
543  /*********************************
544  * User Permissions / File Mounts
545  ********************************/
555  public function ‪addFileMount($folderIdentifier, $additionalData = [])
556  {
557  // check for the folder before we add it as a filemount
558  if ($this->driver->folderExists($folderIdentifier) === false) {
559  // if there is an error, this is important and should be handled
560  // as otherwise the user would see the whole storage without any restrictions for the filemounts
561  throw new ‪FolderDoesNotExistException('Folder for file mount ' . $folderIdentifier . ' does not exist.', 1334427099);
562  }
563  $data = $this->driver->getFolderInfoByIdentifier($folderIdentifier);
564  $folderObject = $this->‪createFolderObject($data['identifier'], $data['name']);
565  // Use the canonical identifier instead of the user provided one!
566  $folderIdentifier = $folderObject->getIdentifier();
567  if (
568  !empty($this->fileMounts[$folderIdentifier])
569  && empty($this->fileMounts[$folderIdentifier]['read_only'])
570  && !empty($additionalData['read_only'])
571  ) {
572  // Do not overwrite a regular mount with a read only mount
573  return;
574  }
575  if (empty($additionalData)) {
576  $additionalData = [
577  'path' => $folderIdentifier,
578  'title' => $folderIdentifier,
579  'folder' => $folderObject,
580  ];
581  } else {
582  $additionalData['folder'] = $folderObject;
583  if (!isset($additionalData['title'])) {
584  $additionalData['title'] = $folderIdentifier;
585  }
586  }
587  $this->fileMounts[$folderIdentifier] = $additionalData;
588  }
589 
595  public function ‪getFileMounts()
596  {
597  return ‪$this->fileMounts;
598  }
599 
608  public function ‪isWithinFileMountBoundaries($subject, $checkWriteAccess = false)
609  {
610  if (!$this->evaluatePermissions) {
611  return true;
612  }
613  $isWithinFileMount = false;
614  if (!$subject) {
615  $subject = $this->‪getRootLevelFolder();
616  }
617  ‪$identifier = $subject->getIdentifier();
618 
619  // Allow access to processing folder
621  $isWithinFileMount = true;
622  } else {
623  // Check if the identifier of the subject is within at
624  // least one of the file mounts
625  $writableFileMountAvailable = false;
626  foreach ($this->fileMounts as $fileMount) {
628  $folder = $fileMount['folder'];
629  if ($this->driver->isWithin($folder->‪getIdentifier(), ‪$identifier)) {
630  $isWithinFileMount = true;
631  if (!$checkWriteAccess) {
632  break;
633  }
634  if (empty($fileMount['read_only'])) {
635  $writableFileMountAvailable = true;
636  break;
637  }
638  }
639  }
640  $isWithinFileMount = $checkWriteAccess ? $writableFileMountAvailable : $isWithinFileMount;
641  }
642  return $isWithinFileMount;
643  }
644 
652  {
653  $this->evaluatePermissions = (bool)‪$evaluatePermissions;
654  }
655 
662  public function ‪getEvaluatePermissions()
663  {
665  }
666 
670  public function ‪setUserPermissions(array ‪$userPermissions)
671  {
672  $this->userPermissions = ‪$userPermissions;
673  }
674 
683  public function ‪checkUserActionPermission($action, $type)
684  {
685  if (!$this->evaluatePermissions) {
686  return true;
687  }
688 
689  $allow = false;
690  if (!empty($this->userPermissions[strtolower($action) . ucfirst(strtolower($type))])) {
691  $allow = true;
692  }
693 
694  return $allow;
695  }
696 
710  public function ‪checkFileActionPermission($action, ‪FileInterface $file)
711  {
712  $isProcessedFile = $file instanceof ‪ProcessedFile;
713  // Check 1: Allow editing meta data of a file if it is in mount boundaries of a writable file mount
714  if ($action === 'editMeta') {
715  return !$isProcessedFile && $this->‪isWithinFileMountBoundaries($file, true);
716  }
717  // Check 2: Does the user have permission to perform the action? e.g. "readFile"
718  if (!$isProcessedFile && $this->‪checkUserActionPermission($action, 'File') === false) {
719  return false;
720  }
721  // Check 3: No action allowed on files for denied file extensions
722  if (!$this->‪checkFileExtensionPermission($file->‪getName())) {
723  return false;
724  }
725  $isReadCheck = false;
726  if (in_array($action, ['read', 'copy', 'move', 'replace'], true)) {
727  $isReadCheck = true;
728  }
729  $isWriteCheck = false;
730  if (in_array($action, ['add', 'write', 'move', 'rename', 'replace', 'delete'], true)) {
731  $isWriteCheck = true;
732  }
733  // Check 4: Does the user have the right to perform the action?
734  // (= is he within the file mount borders)
735  if (!$isProcessedFile && !$this->‪isWithinFileMountBoundaries($file, $isWriteCheck)) {
736  return false;
737  }
738 
739  $isMissing = false;
740  if (!$isProcessedFile && $file instanceof ‪File) {
741  $isMissing = $file->isMissing();
742  }
743 
744  if ($this->driver->fileExists($file->‪getIdentifier()) === false) {
745  $file->setMissing(true);
746  $isMissing = true;
747  }
748 
749  // Check 5: Check the capabilities of the storage (and the driver)
750  if ($isWriteCheck && ($isMissing || !$this->‪isWritable())) {
751  return false;
752  }
753 
754  // Check 6: "File permissions" of the driver (only when file isn't marked as missing)
755  if (!$isMissing) {
756  $filePermissions = $this->driver->getPermissions($file->‪getIdentifier());
757  if ($isReadCheck && !$filePermissions['r']) {
758  return false;
759  }
760  if ($isWriteCheck && !$filePermissions['w']) {
761  return false;
762  }
763  }
764  return true;
765  }
766 
777  public function ‪checkFolderActionPermission($action, Folder $folder = null)
778  {
779  // Check 1: Does the user have permission to perform the action? e.g. "writeFolder"
780  if ($this->‪checkUserActionPermission($action, 'Folder') === false) {
781  return false;
782  }
783 
784  // If we do not have a folder here, we cannot do further checks
785  if ($folder === null) {
786  return true;
787  }
788 
789  $isReadCheck = false;
790  if (in_array($action, ['read', 'copy'], true)) {
791  $isReadCheck = true;
792  }
793  $isWriteCheck = false;
794  if (in_array($action, ['add', 'move', 'write', 'delete', 'rename'], true)) {
795  $isWriteCheck = true;
796  }
797  // Check 2: Does the user has the right to perform the action?
798  // (= is he within the file mount borders)
799  if (!$this->‪isWithinFileMountBoundaries($folder, $isWriteCheck)) {
800  return false;
801  }
802  // Check 3: Check the capabilities of the storage (and the driver)
803  if ($isReadCheck && !$this->‪isBrowsable()) {
804  return false;
805  }
806  if ($isWriteCheck && !$this->‪isWritable()) {
807  return false;
808  }
809 
810  // Check 4: "Folder permissions" of the driver
811  $folderPermissions = $this->driver->getPermissions($folder->‪getIdentifier());
812  if ($isReadCheck && !$folderPermissions['r']) {
813  return false;
814  }
815  if ($isWriteCheck && !$folderPermissions['w']) {
816  return false;
817  }
818  return true;
819  }
820 
828  protected function ‪checkFileExtensionPermission($fileName)
829  {
830  $fileName = $this->driver->sanitizeFileName($fileName);
831  return GeneralUtility::makeInstance(FileNameValidator::class)->isValid($fileName);
832  }
833 
840  protected function ‪assureFolderReadPermission(Folder $folder = null)
841  {
842  if (!$this->‪checkFolderActionPermission('read', $folder)) {
843  if ($folder === null) {
844  throw new InsufficientFolderAccessPermissionsException(
845  'You are not allowed to read folders',
846  1430657869
847  );
848  }
849  throw new InsufficientFolderAccessPermissionsException(
850  'You are not allowed to access the given folder: "' . $folder->‪getName() . '"',
851  1375955684
852  );
853  }
854  }
855 
865  protected function ‪assureFolderDeletePermission(Folder $folder, $checkDeleteRecursively)
866  {
867  // Check user permissions for recursive deletion if it is requested
868  if ($checkDeleteRecursively && !$this->‪checkUserActionPermission('recursivedelete', 'Folder')) {
869  throw new InsufficientUserPermissionsException('You are not allowed to delete folders recursively', 1377779423);
870  }
871  // Check user action permission
872  if (!$this->‪checkFolderActionPermission('delete', $folder)) {
873  throw new InsufficientFolderAccessPermissionsException(
874  'You are not allowed to delete the given folder: "' . $folder->getName() . '"',
875  1377779039
876  );
877  }
878  // Check if the user has write permissions to folders
879  // Would be good if we could check for actual write permissions in the containing folder
880  // but we cannot since we have no access to the containing folder of this file.
881  if (!$this->‪checkUserActionPermission('write', 'Folder')) {
882  throw new ‪InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377779111);
883  }
884  }
885 
892  protected function ‪assureFileReadPermission(FileInterface $file)
893  {
894  if (!$this->‪checkFileActionPermission('read', $file)) {
895  throw new InsufficientFileAccessPermissionsException(
896  'You are not allowed to access that file: "' . $file->getName() . '"',
897  1375955429
898  );
899  }
900  if (!$this->‪checkFileExtensionPermission($file->getName())) {
902  'You are not allowed to use that file extension. File: "' . $file->getName() . '"',
903  1375955430
904  );
905  }
906  }
907 
915  protected function ‪assureFileWritePermissions(FileInterface $file)
916  {
917  // Check if user is allowed to write the file and $file is writable
918  if (!$this->‪checkFileActionPermission('write', $file)) {
919  throw new ‪InsufficientFileWritePermissionsException('Writing to file "' . $file->getIdentifier() . '" is not allowed.', 1330121088);
920  }
921  if (!$this->‪checkFileExtensionPermission($file->getName())) {
922  throw new ‪IllegalFileExtensionException('You are not allowed to edit a file with extension "' . $file->getExtension() . '"', 1366711933);
923  }
924  }
925 
932  protected function ‪assureFileReplacePermissions(FileInterface $file)
933  {
934  // Check if user is allowed to replace the file and $file is writable
935  if (!$this->‪checkFileActionPermission('replace', $file)) {
936  throw new InsufficientFileWritePermissionsException('Replacing file "' . $file->getIdentifier() . '" is not allowed.', 1436899571);
937  }
938  // Check if parentFolder is writable for the user
939  if (!$this->‪checkFolderActionPermission('write', $file->getParentFolder())) {
940  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $file->getIdentifier() . '"', 1436899572);
941  }
942  }
943 
951  protected function ‪assureFileDeletePermissions(FileInterface $file)
952  {
953  // Check for disallowed file extensions
954  if (!$this->‪checkFileExtensionPermission($file->getName())) {
955  throw new IllegalFileExtensionException('You are not allowed to delete a file with extension "' . $file->getExtension() . '"', 1377778916);
956  }
957  // Check further permissions if file is not a processed file
958  if (!$file instanceof ProcessedFile) {
959  // Check if user is allowed to delete the file and $file is writable
960  if (!$this->‪checkFileActionPermission('delete', $file)) {
961  throw new InsufficientFileWritePermissionsException('You are not allowed to delete the file "' . $file->getIdentifier() . '"', 1319550425);
962  }
963  // Check if the user has write permissions to folders
964  // Would be good if we could check for actual write permissions in the containing folder
965  // but we cannot since we have no access to the containing folder of this file.
966  if (!$this->‪checkUserActionPermission('write', 'Folder')) {
967  throw new InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377778702);
968  }
969  }
970  }
971 
983  protected function ‪assureFileAddPermissions($targetFolder, $targetFileName)
984  {
985  // Check for a valid file extension
986  if (!$this->‪checkFileExtensionPermission($targetFileName)) {
987  throw new IllegalFileExtensionException('Extension of file name is not allowed in "' . $targetFileName . '"!', 1322120271);
988  }
989  // Makes sure the user is allowed to upload
990  if (!$this->‪checkUserActionPermission('add', 'File')) {
991  throw new InsufficientUserPermissionsException('You are not allowed to add files to this storage "' . $this->‪getUid() . '"', 1376992145);
992  }
993  // Check if targetFolder is writable
994  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
995  throw new InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetFolder->getIdentifier() . '"', 1322120356);
996  }
997  }
998 
1014  protected function ‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileSize)
1015  {
1016  // Makes sure this is an uploaded file
1017  if (!is_uploaded_file($localFilePath)) {
1018  throw new UploadException('The upload has failed, no uploaded file found!', 1322110455);
1019  }
1020  // Max upload size (kb) for files.
1021  $maxUploadFileSize = GeneralUtility::getMaxUploadFileSize() * 1024;
1022  if ($maxUploadFileSize > 0 && $uploadedFileSize >= $maxUploadFileSize) {
1023  unlink($localFilePath);
1024  throw new ‪UploadSizeException('The uploaded file exceeds the size-limit of ' . $maxUploadFileSize . ' bytes', 1322110041);
1025  }
1026  $this->‪assureFileAddPermissions($targetFolder, $targetFileName);
1027  }
1028 
1038  protected function ‪assureFileMovePermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
1039  {
1040  // Check if targetFolder is within this storage
1041  if ($this->‪getUid() !== $targetFolder->getStorage()->getUid()) {
1042  throw new \RuntimeException('The target folder is not in the same storage. Target folder given: "' . $targetFolder->getIdentifier() . '"', 1422553107);
1043  }
1044  // Check for a valid file extension
1045  if (!$this->‪checkFileExtensionPermission($targetFileName)) {
1046  throw new IllegalFileExtensionException('Extension of file name is not allowed in "' . $targetFileName . '"!', 1378243279);
1047  }
1048  // Check if user is allowed to move and $file is readable and writable
1049  if (!$file->getStorage()->checkFileActionPermission('move', $file)) {
1050  throw new InsufficientUserPermissionsException('You are not allowed to move files to storage "' . $this->‪getUid() . '"', 1319219349);
1051  }
1052  // Check if target folder is writable
1053  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1054  throw new ‪InsufficientFolderAccessPermissionsException('You are not allowed to write to the target folder "' . $targetFolder->getIdentifier() . '"', 1319219350);
1055  }
1056  }
1057 
1067  protected function ‪assureFileRenamePermissions(FileInterface $file, $targetFileName)
1068  {
1069  // Check if file extension is allowed
1070  if (!$this->‪checkFileExtensionPermission($targetFileName) || !$this->‪checkFileExtensionPermission($file->getName())) {
1071  throw new IllegalFileExtensionException('You are not allowed to rename a file with this extension. File given: "' . $file->getName() . '"', 1371466663);
1072  }
1073  // Check if user is allowed to rename
1074  if (!$this->‪checkFileActionPermission('rename', $file)) {
1075  throw new InsufficientUserPermissionsException('You are not allowed to rename files. File given: "' . $file->getName() . '"', 1319219351);
1076  }
1077  // Check if the user is allowed to write to folders
1078  // Although it would be good to check, we cannot check here if the folder actually is writable
1079  // because we do not know in which folder the file resides.
1080  // So we rely on the driver to throw an exception in case the renaming failed.
1081  if (!$this->‪checkFolderActionPermission('write')) {
1082  throw new InsufficientFileWritePermissionsException('You are not allowed to write to folders', 1319219352);
1083  }
1084  }
1085 
1098  protected function ‪assureFileCopyPermissions(‪FileInterface $file, ‪Folder $targetFolder, $targetFileName)
1099  {
1100  // Check if targetFolder is within this storage, this should never happen
1101  if ($this->‪getUid() != $targetFolder->‪getStorage()->‪getUid()) {
1102  throw new ‪Exception('The operation of the folder cannot be called by this storage "' . $this->‪getUid() . '"', 1319550405);
1103  }
1104  // Check if user is allowed to copy
1105  if (!$file->‪getStorage()->‪checkFileActionPermission('copy', $file)) {
1106  throw new InsufficientFileReadPermissionsException('You are not allowed to copy the file "' . $file->‪getIdentifier() . '"', 1319550426);
1107  }
1108  // Check if targetFolder is writable
1109  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1110  throw new InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetFolder->‪getIdentifier() . '"', 1319550435);
1111  }
1112  // Check for a valid file extension
1113  if (!$this->‪checkFileExtensionPermission($targetFileName) || !$this->‪checkFileExtensionPermission($file->‪getName())) {
1114  throw new IllegalFileExtensionException('You are not allowed to copy a file of that type.', 1319553317);
1115  }
1116  }
1117 
1130  protected function ‪assureFolderCopyPermissions(‪FolderInterface $folderToCopy, ‪FolderInterface $targetParentFolder)
1131  {
1132  // Check if targetFolder is within this storage, this should never happen
1133  if ($this->‪getUid() !== $targetParentFolder->‪getStorage()->‪getUid()) {
1134  throw new ‪Exception('The operation of the folder cannot be called by this storage "' . $this->‪getUid() . '"', 1377777624);
1135  }
1136  if (!$folderToCopy instanceof Folder) {
1137  throw new \RuntimeException('The folder "' . $folderToCopy->‪getIdentifier() . '" to copy is not of type folder.', 1384209020);
1138  }
1139  // Check if user is allowed to copy and the folder is readable
1140  if (!$folderToCopy->‪getStorage()->‪checkFolderActionPermission('copy', $folderToCopy)) {
1141  throw new InsufficientFileReadPermissionsException('You are not allowed to copy the folder "' . $folderToCopy->‪getIdentifier() . '"', 1377777629);
1142  }
1143  if (!$targetParentFolder instanceof Folder) {
1144  throw new \RuntimeException('The target folder "' . $targetParentFolder->‪getIdentifier() . '" is not of type folder.', 1384209021);
1145  }
1146  // Check if targetFolder is writable
1147  if (!$this->‪checkFolderActionPermission('write', $targetParentFolder)) {
1148  throw new InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetParentFolder->‪getIdentifier() . '"', 1377777635);
1149  }
1150  }
1151 
1164  protected function ‪assureFolderMovePermissions(‪FolderInterface $folderToMove, ‪FolderInterface $targetParentFolder)
1165  {
1166  // Check if targetFolder is within this storage, this should never happen
1167  if ($this->‪getUid() !== $targetParentFolder->‪getStorage()->‪getUid()) {
1168  throw new \InvalidArgumentException('Cannot move a folder into a folder that does not belong to this storage.', 1325777289);
1169  }
1170  if (!$folderToMove instanceof Folder) {
1171  throw new \RuntimeException('The folder "' . $folderToMove->‪getIdentifier() . '" to move is not of type Folder.', 1384209022);
1172  }
1173  // Check if user is allowed to move and the folder is writable
1174  // In fact we would need to check if the parent folder of the folder to move is writable also
1175  // But as of now we cannot extract the parent folder from this folder
1176  if (!$folderToMove->‪getStorage()->‪checkFolderActionPermission('move', $folderToMove)) {
1177  throw new InsufficientFileReadPermissionsException('You are not allowed to copy the folder "' . $folderToMove->‪getIdentifier() . '"', 1377778045);
1178  }
1179  if (!$targetParentFolder instanceof Folder) {
1180  throw new \RuntimeException('The target folder "' . $targetParentFolder->‪getIdentifier() . '" is not of type Folder.', 1384209023);
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() . '"', 1377778049);
1185  }
1186  }
1187 
1196  public function ‪sanitizeFileName($fileName, Folder $targetFolder = null)
1197  {
1198  $targetFolder = $targetFolder ?: $this->‪getDefaultFolder();
1199  $fileName = $this->driver->sanitizeFileName($fileName);
1200 
1201  // The file name could be changed by an event listener
1202  $fileName = $this->eventDispatcher->dispatch(
1203  new SanitizeFileNameEvent($fileName, $targetFolder, ‪$this, $this->driver)
1204  )->getFileName();
1205 
1206  return $fileName;
1207  }
1208 
1209  /********************
1210  * FILE ACTIONS
1211  ********************/
1225  public function ‪addFile($localFilePath, ‪Folder $targetFolder, $targetFileName = '', $conflictMode = ‪DuplicationBehavior::RENAME, $removeOriginal = true)
1226  {
1227  $localFilePath = ‪PathUtility::getCanonicalPath($localFilePath);
1228  // File is not available locally NOR is it an uploaded file
1229  if (!is_uploaded_file($localFilePath) && !file_exists($localFilePath)) {
1230  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552745);
1231  }
1232  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
1233  $targetFileName = $this->‪sanitizeFileName($targetFileName ?: ‪PathUtility::basename($localFilePath), $targetFolder);
1234 
1235  $targetFileName = $this->eventDispatcher->dispatch(
1236  new ‪BeforeFileAddedEvent($targetFileName, $localFilePath, $targetFolder, ‪$this, $this->driver)
1237  )->getFileName();
1238 
1239  $this->‪assureFileAddPermissions($targetFolder, $targetFileName);
1240 
1241  $replaceExisting = false;
1242  if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && ‪$this->driver->fileExistsInFolder($targetFileName, $targetFolder->‪getIdentifier())) {
1243  throw new ‪ExistingTargetFileNameException('File "' . $targetFileName . '" already exists in folder ' . $targetFolder->‪getIdentifier(), 1322121068);
1244  }
1245  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
1246  $targetFileName = $this->‪getUniqueName($targetFolder, $targetFileName);
1247  } elseif ($conflictMode->equals(‪DuplicationBehavior::REPLACE) && ‪$this->driver->fileExistsInFolder($targetFileName, $targetFolder->‪getIdentifier())) {
1248  $replaceExisting = true;
1249  }
1250 
1251  $fileIdentifier = $this->driver->addFile($localFilePath, $targetFolder->‪getIdentifier(), $targetFileName, $removeOriginal);
1252  $file = $this->‪getFileByIdentifier($fileIdentifier);
1253 
1254  if ($replaceExisting && $file instanceof ‪File) {
1255  $this->‪getIndexer()->‪updateIndexEntry($file);
1256  }
1257 
1258  $this->eventDispatcher->dispatch(
1259  new ‪AfterFileAddedEvent($file, $targetFolder)
1260  );
1261  return $file;
1262  }
1263 
1272  public function ‪updateProcessedFile($localFilePath, ‪ProcessedFile $processedFile, ‪Folder ‪$processingFolder = null)
1273  {
1274  if (!file_exists($localFilePath)) {
1275  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552746);
1276  }
1277  if (‪$processingFolder === null) {
1279  }
1280  $fileIdentifier = $this->driver->addFile($localFilePath, ‪$processingFolder->‪getIdentifier(), $processedFile->‪getName());
1281  // @todo check if we have to update the processed file other then the identifier
1282  $processedFile->‪setIdentifier($fileIdentifier);
1283  return $processedFile;
1284  }
1285 
1293  public function ‪hashFile(FileInterface $fileObject, $hash)
1294  {
1295  return $this->‪hashFileByIdentifier($fileObject->getIdentifier(), $hash);
1296  }
1297 
1306  public function ‪hashFileByIdentifier($fileIdentifier, $hash)
1307  {
1308  $hash = $this->driver->hash($fileIdentifier, $hash);
1309  if (!is_string($hash) || $hash === '') {
1310  throw new ‪InvalidHashException('Hash has to be non-empty string.', 1551950301);
1311  }
1312  return $hash;
1313  }
1314 
1323  public function ‪hashFileIdentifier($file)
1324  {
1325  if (is_object($file) && $file instanceof FileInterface) {
1327  $file = $file->‪getIdentifier();
1328  }
1329  return $this->driver->hashIdentifier($file);
1330  }
1331 
1341  public function ‪getPublicUrl(ResourceInterface $resourceObject)
1342  {
1343  ‪$publicUrl = null;
1344  if ($this->‪isOnline()) {
1345  // Pre-process the public URL by an accordant event
1346  $event = new GeneratePublicUrlForResourceEvent($resourceObject, ‪$this, $this->driver);
1347  ‪$publicUrl = $this->eventDispatcher->dispatch($event)->getPublicUrl();
1348  if (
1349  ‪$publicUrl === null
1350  && $resourceObject instanceof File
1351  && ($helper = GeneralUtility::makeInstance(OnlineMediaHelperRegistry::class)->getOnlineMediaHelper($resourceObject)) !== false
1352  ) {
1353  ‪$publicUrl = $helper->getPublicUrl($resourceObject);
1354  }
1355 
1356  // If an event listener did not handle the URL generation, use the default way to determine public URL
1357  if (‪$publicUrl === null) {
1358  if ($this->‪hasCapability(self::CAPABILITY_PUBLIC)) {
1359  ‪$publicUrl = $this->driver->getPublicUrl($resourceObject->getIdentifier());
1360  }
1361 
1362  if (‪$publicUrl === null && $resourceObject instanceof FileInterface) {
1363  $queryParameterArray = ['eID' => 'dumpFile', 't' => ''];
1364  if ($resourceObject instanceof File) {
1365  $queryParameterArray['f'] = $resourceObject->getUid();
1366  $queryParameterArray['t'] = 'f';
1367  } elseif ($resourceObject instanceof ProcessedFile) {
1368  $queryParameterArray['p'] = $resourceObject->getUid();
1369  $queryParameterArray['t'] = 'p';
1370  }
1371 
1372  $queryParameterArray['token'] = ‪GeneralUtility::hmac(implode('|', $queryParameterArray), 'resourceStorageDumpFile');
1373  ‪$publicUrl = GeneralUtility::locationHeaderUrl(‪PathUtility::getAbsoluteWebPath(‪Environment::getPublicPath() . '/index.php'));
1374  ‪$publicUrl .= '?' . http_build_query($queryParameterArray, '', '&', PHP_QUERY_RFC3986);
1375  }
1376  }
1377  }
1378  return ‪$publicUrl;
1379  }
1380 
1390  public function ‪processFile(FileInterface $fileObject, $context, array ‪$configuration)
1391  {
1392  if ($fileObject->getStorage() !== ‪$this) {
1393  throw new \InvalidArgumentException('Cannot process files of foreign storage', 1353401835);
1394  }
1395  $processedFile = $this->‪getFileProcessingService()->‪processFile($fileObject, ‪$this, $context, ‪$configuration);
1396 
1397  return $processedFile;
1398  }
1399 
1406  public function ‪getFileForLocalProcessing(FileInterface $fileObject, $writable = true)
1407  {
1408  $filePath = $this->driver->getFileForLocalProcessing($fileObject->getIdentifier(), $writable);
1409  return $filePath;
1410  }
1411 
1418  public function ‪getFile(‪$identifier)
1419  {
1421  if (!$this->driver->fileExists(‪$identifier)) {
1422  $file->setMissing(true);
1423  }
1424  return $file;
1425  }
1426 
1434  public function ‪getFileByIdentifier(string $fileIdentifier)
1435  {
1436  if (!$this->‪isWithinProcessingFolder($fileIdentifier)) {
1437  $fileData = $this->‪getFileIndexRepository()->‪findOneByStorageAndIdentifier(‪$this, $fileIdentifier);
1438  if ($fileData === false) {
1439  return $this->‪getIndexer()->‪createIndexEntry($fileIdentifier);
1440  }
1441  return $this->‪getResourceFactoryInstance()->getFileObject($fileData['uid'], $fileData);
1442  }
1443  return $this->‪getProcessedFileRepository()->findByStorageAndIdentifier(‪$this, $fileIdentifier);
1444  }
1445 
1447  {
1448  return GeneralUtility::makeInstance(ProcessedFileRepository::class);
1449  }
1450 
1457  public function ‪getFileInfo(FileInterface $fileObject)
1458  {
1459  return $this->‪getFileInfoByIdentifier($fileObject->getIdentifier());
1460  }
1461 
1469  public function ‪getFileInfoByIdentifier(‪$identifier, array $propertiesToExtract = [])
1470  {
1471  return $this->driver->getFileInfoByIdentifier(‪$identifier, $propertiesToExtract);
1472  }
1473 
1477  public function ‪unsetFileAndFolderNameFilters()
1478  {
1479  $this->‪fileAndFolderNameFilters = [];
1480  }
1481 
1486  {
1487  $this->‪fileAndFolderNameFilters = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['defaultFilterCallbacks'];
1488  }
1489 
1496  public function getImportExportFilter(): array
1497  {
1498  $filter = GeneralUtility::makeInstance(ImportExportFilter::class);
1499 
1500  return [$filter, 'filterImportExportFilesAndFolders'];
1501  }
1502 
1508  public function ‪getFileAndFolderNameFilters()
1509  {
1510  return array_merge($this->‪fileAndFolderNameFilters, [$this->getImportExportFilter()]);
1511  }
1512 
1516  public function setFileAndFolderNameFilters(array $filters)
1517  {
1518  $this->‪fileAndFolderNameFilters = $filters;
1519  return ‪$this;
1520  }
1525  public function ‪addFileAndFolderNameFilter($filter)
1526  {
1527  $this->‪fileAndFolderNameFilters[] = $filter;
1528  }
1529 
1535  public function ‪getFolderIdentifierFromFileIdentifier($fileIdentifier)
1536  {
1537  return $this->driver->getParentFolderIdentifierOfIdentifier($fileIdentifier);
1538  }
1539 
1546  public function ‪getFileInFolder($fileName, Folder $folder)
1547  {
1548  ‪$identifier = $this->driver->getFileInFolder($fileName, $folder->getIdentifier());
1549  return $this->‪getFileByIdentifier(‪$identifier);
1550  }
1551 
1566  public function ‪getFilesInFolder(Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
1567  {
1568  $this->‪assureFolderReadPermission($folder);
1569 
1570  $rows = $this->‪getFileIndexRepository()->‪findByFolder($folder);
1571 
1572  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
1573  $fileIdentifiers = array_values($this->driver->getFilesInFolder($folder->getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev));
1574 
1575  $items = [];
1576  foreach ($fileIdentifiers as ‪$identifier) {
1577  if (isset($rows[‪$identifier])) {
1578  $fileObject = $this->‪getFileFactory()->‪getFileObject($rows[‪$identifier]['uid'], $rows[‪$identifier]);
1579  } else {
1580  $fileObject = $this->‪getFileByIdentifier($identifier);
1581  }
1582  if ($fileObject instanceof FileInterface) {
1583  $key = $fileObject->getName();
1584  while (isset($items[$key])) {
1585  $key .= 'z';
1586  }
1587  $items[$key] = $fileObject;
1588  }
1589  }
1590 
1591  return $items;
1592  }
1593 
1600  public function ‪getFileIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
1601  {
1602  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
1603  return $this->driver->getFilesInFolder($folderIdentifier, 0, 0, $recursive, $filters);
1604  }
1605 
1612  public function ‪countFilesInFolder(Folder $folder, $useFilters = true, $recursive = false)
1613  {
1614  $this->‪assureFolderReadPermission($folder);
1615  $filters = $useFilters ? $this->‪getFileAndFolderNameFilters() : [];
1616  return $this->driver->countFilesInFolder($folder->getIdentifier(), $recursive, $filters);
1617  }
1618 
1625  public function ‪getFolderIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
1626  {
1627  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
1628  return $this->driver->getFoldersInFolder($folderIdentifier, 0, 0, $recursive, $filters);
1629  }
1630 
1637  public function ‪hasFile(‪$identifier)
1638  {
1639  // Allow if identifier is in processing folder
1640  if (!$this->‪isWithinProcessingFolder($identifier)) {
1642  }
1643  return $this->driver->fileExists(‪$identifier);
1644  }
1645 
1651  public function ‪getProcessingFolders()
1652  {
1653  if ($this->processingFolders === null) {
1654  $this->processingFolders = [];
1655  $this->processingFolders[] = $this->‪getProcessingFolder();
1656  $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
1657  $allStorages = $storageRepository->findAll();
1658  foreach ($allStorages as $storage) {
1659  // To circumvent the permission check of the folder, we use the factory to create it "manually" instead of directly using $storage->getProcessingFolder()
1660  // See #66695 for details
1661  [$storageUid, $processingFolderIdentifier] = array_pad(‪GeneralUtility::trimExplode(':', $storage->getStorageRecord()['processingfolder']), 2, null);
1662  if (empty($processingFolderIdentifier) || (int)$storageUid !== $this->‪getUid()) {
1663  continue;
1664  }
1665  $potentialProcessingFolder = $this->‪createFolderObject($processingFolderIdentifier, $processingFolderIdentifier);
1666  if ($potentialProcessingFolder->getStorage() === ‪$this && $potentialProcessingFolder->getIdentifier() !== ‪$this->getProcessingFolder()->getIdentifier()) {
1667  $this->processingFolders[] = $potentialProcessingFolder;
1668  }
1669  }
1670  }
1671 
1673  }
1674 
1681  public function ‪isProcessingFolder(Folder $folder)
1682  {
1683  $isProcessingFolder = false;
1684  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
1685  if ($folder->getCombinedIdentifier() === ‪$processingFolder->‪getCombinedIdentifier()) {
1686  $isProcessingFolder = true;
1687  break;
1688  }
1689  }
1690  return $isProcessingFolder;
1691  }
1692 
1699  public function ‪hasFileInFolder($fileName, ‪Folder $folder)
1700  {
1701  $this->‪assureFolderReadPermission($folder);
1702  return $this->driver->fileExistsInFolder($fileName, $folder->‪getIdentifier());
1703  }
1704 
1713  public function ‪getFileContents($file)
1714  {
1715  $this->‪assureFileReadPermission($file);
1716  return $this->driver->getFileContents($file->‪getIdentifier());
1717  }
1718 
1726  public function ‪streamFile(
1727  FileInterface $file,
1728  bool $asDownload = false,
1729  string $alternativeFilename = null,
1730  string $overrideMimeType = null
1731  ): ResponseInterface {
1732  if (!$this->driver instanceof StreamableDriverInterface) {
1733  return $this->‪getPseudoStream($file, $asDownload, $alternativeFilename, $overrideMimeType);
1734  }
1735 
1736  $properties = [
1737  'as_download' => $asDownload,
1738  'filename_overwrite' => $alternativeFilename,
1739  'mimetype_overwrite' => $overrideMimeType,
1740  ];
1741  return $this->driver->streamFile($file->getIdentifier(), $properties);
1742  }
1743 
1752  protected function ‪getPseudoStream(
1753  ‪FileInterface $file,
1754  bool $asDownload = false,
1755  string $alternativeFilename = null,
1756  string $overrideMimeType = null
1757  ) {
1758  $downloadName = $alternativeFilename ?: $file->‪getName();
1759  $contentDisposition = $asDownload ? 'attachment' : 'inline';
1760 
1761  $stream = new ‪FalDumpFileContentsDecoratorStream($file->‪getIdentifier(), ‪$this->driver, $file->‪getSize());
1762  $fileInfo = $this->driver->getFileInfoByIdentifier($file->‪getIdentifier(), ['mtime']);
1763  $headers = [
1764  'Content-Disposition' => $contentDisposition . '; filename="' . $downloadName . '"',
1765  'Content-Type' => $overrideMimeType ?: $file->‪getMimeType(),
1766  'Content-Length' => (string)$file->‪getSize(),
1767  'Last-Modified' => gmdate('D, d M Y H:i:s', array_pop($fileInfo)) . ' GMT',
1768  // Cache-Control header is needed here to solve an issue with browser IE8 and lower
1769  // See for more information: http://support.microsoft.com/kb/323308
1770  'Cache-Control' => '',
1771  ];
1773  return new ‪Response($stream, 200, $headers);
1774  }
1775 
1786  public function ‪setFileContents(‪AbstractFile $file, $contents)
1787  {
1788  // Check if user is allowed to edit
1789  $this->‪assureFileWritePermissions($file);
1790  $this->eventDispatcher->dispatch(
1791  new ‪BeforeFileContentsSetEvent($file, $contents)
1792  );
1793  // Call driver method to update the file and update file index entry afterwards
1794  $result = $this->driver->setFileContents($file->‪getIdentifier(), $contents);
1795  if ($file instanceof ‪File) {
1796  $this->‪getIndexer()->‪updateIndexEntry($file);
1797  }
1798  $this->eventDispatcher->dispatch(
1799  new AfterFileContentsSetEvent($file, $contents)
1800  );
1801  return $result;
1802  }
1803 
1816  public function ‪createFile($fileName, ‪Folder $targetFolderObject)
1817  {
1818  $this->‪assureFileAddPermissions($targetFolderObject, $fileName);
1819  $this->eventDispatcher->dispatch(
1820  new ‪BeforeFileCreatedEvent($fileName, $targetFolderObject)
1821  );
1822  $newFileIdentifier = $this->driver->createFile($fileName, $targetFolderObject->‪getIdentifier());
1823  $this->eventDispatcher->dispatch(
1824  new ‪AfterFileCreatedEvent($newFileIdentifier, $targetFolderObject)
1825  );
1826  return $this->‪getFileByIdentifier($newFileIdentifier);
1827  }
1828 
1837  public function ‪deleteFile($fileObject)
1838  {
1839  $this->‪assureFileDeletePermissions($fileObject);
1840 
1841  $this->eventDispatcher->dispatch(
1842  new ‪BeforeFileDeletedEvent($fileObject)
1843  );
1844  $deleted = true;
1845 
1846  if ($this->driver->fileExists($fileObject->getIdentifier())) {
1847  // Disable permission check to find nearest recycler and move file without errors
1848  $currentPermissions = ‪$this->evaluatePermissions;
1849  $this->evaluatePermissions = false;
1850 
1851  $recyclerFolder = $this->‪getNearestRecyclerFolder($fileObject);
1852  if ($recyclerFolder === null) {
1853  $result = $this->driver->deleteFile($fileObject->getIdentifier());
1854  } else {
1855  $result = $this->‪moveFile($fileObject, $recyclerFolder);
1856  $deleted = false;
1857  }
1858 
1859  $this->evaluatePermissions = $currentPermissions;
1860 
1861  if (!$result) {
1862  throw new FileOperationErrorException('Deleting the file "' . $fileObject->getIdentifier() . '\' failed.', 1329831691);
1863  }
1864  }
1865  // Mark the file object as deleted
1866  if ($deleted && $fileObject instanceof AbstractFile) {
1867  $fileObject->setDeleted();
1868  }
1869 
1870  $this->eventDispatcher->dispatch(
1871  new AfterFileDeletedEvent($fileObject)
1872  );
1873 
1874  return true;
1875  }
1876 
1889  public function copyFile(FileInterface $file, Folder $targetFolder, $targetFileName = null, $conflictMode = DuplicationBehavior::RENAME)
1890  {
1891  $conflictMode = DuplicationBehavior::cast($conflictMode);
1892  if ($targetFileName === null) {
1893  $targetFileName = $file->getName();
1894  }
1895  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
1896  $this->assureFileCopyPermissions($file, $targetFolder, $sanitizedTargetFileName);
1897 
1898  $this->eventDispatcher->dispatch(
1899  new BeforeFileCopiedEvent($file, $targetFolder)
1900  );
1901 
1902  // File exists and we should abort, let's abort
1903  ‪if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && $targetFolder->‪hasFile($sanitizedTargetFileName)) {
1904  throw new ExistingTargetFileNameException('The target file already exists.', 1320291064);
1905  }
1906  // File exists and we should find another name, let's find another one
1907  ‪if ($conflictMode->equals(‪DuplicationBehavior::RENAME) && $targetFolder->‪hasFile($sanitizedTargetFileName)) {
1908  $sanitizedTargetFileName = $this->getUniqueName($targetFolder, $sanitizedTargetFileName);
1909  }
1910  $sourceStorage = $file->‪getStorage();
1911  // Call driver method to create a new file from an existing file object,
1912  // and return the new file object
1913  ‪if ($sourceStorage === ‪$this) {
1914  $newFileObjectIdentifier = $this->driver->copyFileWithinStorage($file->‪getIdentifier(), $targetFolder->‪getIdentifier(), $sanitizedTargetFileName);
1915  } else {
1916  $tempPath = $file->‪getForLocalProcessing();
1917  $newFileObjectIdentifier = $this->driver->addFile($tempPath, $targetFolder->‪getIdentifier(), $sanitizedTargetFileName);
1918  }
1919  $newFileObject = $this->‪getFileByIdentifier($newFileObjectIdentifier);
1920 
1921  $this->eventDispatcher->dispatch(
1922  new AfterFileCopiedEvent($file, $targetFolder, $newFileObjectIdentifier, $newFileObject)
1923  );
1924  return $newFileObject;
1925  }
1926 
1942  public function ‪moveFile($file, $targetFolder, $targetFileName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
1943  {
1944  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
1945  if ($targetFileName === null) {
1946  $targetFileName = $file->‪getName();
1947  }
1948  $originalFolder = $file->‪getParentFolder();
1949  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
1950  $this->‪assureFileMovePermissions($file, $targetFolder, $sanitizedTargetFileName);
1951  if ($targetFolder->‪hasFile($sanitizedTargetFileName)) {
1952  // File exists and we should abort, let's abort
1953  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
1954  $sanitizedTargetFileName = $this->‪getUniqueName($targetFolder, $sanitizedTargetFileName);
1955  } elseif ($conflictMode->equals(‪DuplicationBehavior::CANCEL)) {
1956  throw new ExistingTargetFileNameException('The target file already exists', 1329850997);
1957  }
1958  }
1959  $this->eventDispatcher->dispatch(
1960  new BeforeFileMovedEvent($file, $targetFolder, $sanitizedTargetFileName)
1961  );
1962  $sourceStorage = $file->‪getStorage();
1963  // Call driver method to move the file and update the index entry
1964  try {
1965  if ($sourceStorage === ‪$this) {
1966  $newIdentifier = $this->driver->moveFileWithinStorage($file->‪getIdentifier(), $targetFolder->‪getIdentifier(), $sanitizedTargetFileName);
1967  if (!$file instanceof AbstractFile) {
1968  throw new \RuntimeException('The given file is not of type AbstractFile.', 1384209025);
1969  }
1970  $file->‪updateProperties(['identifier' => $newIdentifier]);
1971  } else {
1972  $tempPath = $file->‪getForLocalProcessing();
1973  $newIdentifier = $this->driver->addFile($tempPath, $targetFolder->‪getIdentifier(), $sanitizedTargetFileName);
1974 
1975  // Disable permission check to find nearest recycler and move file without errors
1976  $currentPermissions = $sourceStorage->evaluatePermissions;
1977  $sourceStorage->evaluatePermissions = false;
1978 
1979  $recyclerFolder = $sourceStorage->getNearestRecyclerFolder($file);
1980  if ($recyclerFolder === null) {
1981  $sourceStorage->driver->deleteFile($file->‪getIdentifier());
1982  } else {
1983  $sourceStorage->moveFile($file, $recyclerFolder);
1984  }
1985  $sourceStorage->evaluatePermissions = $currentPermissions;
1986  if ($file instanceof File) {
1987  $file->‪updateProperties(['storage' => $this->‪getUid(), 'identifier' => $newIdentifier]);
1988  }
1989  }
1990  $this->‪getIndexer()->‪updateIndexEntry($file);
1991  } catch (\‪TYPO3\CMS\Core\Exception $e) {
1992  echo $e->getMessage();
1993  }
1994  $this->eventDispatcher->dispatch(
1995  new ‪AfterFileMovedEvent($file, $targetFolder, $originalFolder)
1996  );
1997  return $file;
1998  }
1999 
2009  public function ‪renameFile($file, $targetFileName, $conflictMode = ‪DuplicationBehavior::RENAME)
2010  {
2011  // The name should be different from the current.
2012  if ($file->‪getName() === $targetFileName) {
2013  return $file;
2014  }
2015  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
2016  $this->‪assureFileRenamePermissions($file, $sanitizedTargetFileName);
2017  $this->eventDispatcher->dispatch(
2018  new BeforeFileRenamedEvent($file, $sanitizedTargetFileName)
2019  );
2020 
2021  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2022 
2023  // Call driver method to rename the file and update the index entry
2024  try {
2025  $newIdentifier = $this->driver->renameFile($file->‪getIdentifier(), $sanitizedTargetFileName);
2026  if ($file instanceof File) {
2027  $file->‪updateProperties(['identifier' => $newIdentifier]);
2028  }
2029  $this->‪getIndexer()->‪updateIndexEntry($file);
2030  } catch (ExistingTargetFileNameException $exception) {
2031  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
2032  $newName = $this->‪getUniqueName($file->‪getParentFolder(), $sanitizedTargetFileName);
2033  $file = $this->‪renameFile($file, $newName);
2034  } elseif ($conflictMode->equals(‪DuplicationBehavior::CANCEL)) {
2035  throw $exception;
2036  } elseif ($conflictMode->equals(‪DuplicationBehavior::REPLACE)) {
2037  $sourceFileIdentifier = substr($file->‪getCombinedIdentifier(), 0, (int)strrpos($file->‪getCombinedIdentifier(), '/') + 1) . $sanitizedTargetFileName;
2038  $sourceFile = $this->‪getResourceFactoryInstance()->getFileObjectFromCombinedIdentifier($sourceFileIdentifier);
2039  $file = $this->‪replaceFile($sourceFile, ‪Environment::getPublicPath() . '/' . $file->‪getPublicUrl());
2040  }
2041  } catch (\RuntimeException $e) {
2042  }
2043 
2044  $this->eventDispatcher->dispatch(
2045  new AfterFileRenamedEvent($file, $sanitizedTargetFileName)
2046  );
2048  return $file;
2049  }
2050 
2061  public function ‪replaceFile(‪FileInterface $file, $localFilePath)
2062  {
2063  $this->‪assureFileReplacePermissions($file);
2064  if (!file_exists($localFilePath)) {
2065  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1325842622);
2066  }
2067  $this->eventDispatcher->dispatch(
2068  new BeforeFileReplacedEvent($file, $localFilePath)
2069  );
2070  $this->driver->replaceFile($file->‪getIdentifier(), $localFilePath);
2071  if ($file instanceof File) {
2072  $this->‪getIndexer()->‪updateIndexEntry($file);
2073  }
2074  $this->eventDispatcher->dispatch(
2075  new ‪AfterFileReplacedEvent($file, $localFilePath)
2076  );
2077  return $file;
2078  }
2079 
2089  public function ‪addUploadedFile(array|‪UploadedFile $uploadedFileData, ‪Folder $targetFolder = null, $targetFileName = null, $conflictMode = ‪DuplicationBehavior::CANCEL)
2090  {
2091  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2092  if ($uploadedFileData instanceof ‪UploadedFile) {
2093  $localFilePath = $uploadedFileData->‪getTemporaryFileName();
2094  if ($targetFileName === null) {
2095  $targetFileName = $uploadedFileData->‪getClientFilename();
2096  }
2097  $size = $uploadedFileData->‪getSize();
2098  } else {
2099  $localFilePath = $uploadedFileData['tmp_name'];
2100  if ($targetFileName === null) {
2101  $targetFileName = $uploadedFileData['name'];
2102  }
2103  $size = $uploadedFileData['size'];
2104  }
2105  if ($targetFolder === null) {
2106  $targetFolder = $this->‪getDefaultFolder();
2107  }
2108 
2109  $targetFileName = $this->driver->sanitizeFileName($targetFileName);
2110 
2111  $this->‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $size);
2112  if ($this->‪hasFileInFolder($targetFileName, $targetFolder) && $conflictMode->equals(‪DuplicationBehavior::REPLACE)) {
2113  $file = $this->‪getFileInFolder($targetFileName, $targetFolder);
2114  $resultObject = $this->‪replaceFile($file, $localFilePath);
2115  } else {
2116  $resultObject = $this->‪addFile($localFilePath, $targetFolder, $targetFileName, (string)$conflictMode);
2117  }
2118  return $resultObject;
2119  }
2120 
2121  /********************
2122  * FOLDER ACTIONS
2123  ********************/
2129  protected function ‪getAllFileObjectsInFolder(Folder $folder)
2130  {
2131  $files = [];
2132  $folderQueue = [$folder];
2133  while (!empty($folderQueue)) {
2134  $folder = array_shift($folderQueue);
2135  foreach ($folder->getSubfolders() as $subfolder) {
2136  $folderQueue[] = $subfolder;
2137  }
2138  foreach ($folder->getFiles() as $file) {
2140  $files[$file->getIdentifier()] = $file;
2141  }
2142  }
2143 
2144  return $files;
2145  }
2146 
2161  public function ‪moveFolder(Folder $folderToMove, Folder $targetParentFolder, $newFolderName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2162  {
2163  // @todo add tests
2164  $this->‪assureFolderMovePermissions($folderToMove, $targetParentFolder);
2165  $sourceStorage = $folderToMove->getStorage();
2166  $sanitizedNewFolderName = $this->driver->sanitizeFileName($newFolderName ?: $folderToMove->getName());
2167  // @todo check if folder already exists in $targetParentFolder, handle this conflict then
2168  $this->eventDispatcher->dispatch(
2169  new BeforeFolderMovedEvent($folderToMove, $targetParentFolder, $sanitizedNewFolderName)
2170  );
2171  // Get all file objects now so we are able to update them after moving the folder
2172  $fileObjects = $this->‪getAllFileObjectsInFolder($folderToMove);
2173  if ($sourceStorage === ‪$this) {
2174  if ($this->‪isWithinFolder($folderToMove, $targetParentFolder)) {
2175  throw new InvalidTargetFolderException(
2176  sprintf(
2177  'Cannot move folder "%s" into target folder "%s", because the target folder is already within the folder to be moved!',
2178  $folderToMove->getName(),
2179  $targetParentFolder->getName()
2180  ),
2181  1422723050
2182  );
2183  }
2184  $fileMappings = $this->driver->moveFolderWithinStorage($folderToMove->getIdentifier(), $targetParentFolder->getIdentifier(), $sanitizedNewFolderName);
2185  } else {
2186  $fileMappings = $this->‪moveFolderBetweenStorages($folderToMove, $targetParentFolder, $sanitizedNewFolderName);
2187  }
2188  // Update the identifier and storage of all file objects
2189  foreach ($fileObjects as $oldIdentifier => $fileObject) {
2190  $newIdentifier = $fileMappings[$oldIdentifier];
2191  $fileObject->updateProperties(['storage' => $this->‪getUid(), 'identifier' => $newIdentifier]);
2192  $this->‪getIndexer()->‪updateIndexEntry($fileObject);
2193  }
2194  $returnObject = $this->‪getFolder($fileMappings[$folderToMove->getIdentifier()]);
2195 
2196  $this->eventDispatcher->dispatch(
2197  new ‪AfterFolderMovedEvent($folderToMove, $targetParentFolder, $returnObject)
2198  );
2199  return $returnObject;
2200  }
2201 
2208  protected function ‪moveFolderBetweenStorages(‪Folder $folderToMove, ‪Folder $targetParentFolder, $newFolderName)
2209  {
2210  throw new ‪NotImplementedMethodException('Not yet implemented', 1476046361);
2211  }
2212 
2223  public function ‪copyFolder(‪FolderInterface $folderToCopy, ‪FolderInterface $targetParentFolder, $newFolderName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2224  {
2225  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2226  $this->‪assureFolderCopyPermissions($folderToCopy, $targetParentFolder);
2227  $returnObject = null;
2228  $sanitizedNewFolderName = $this->driver->sanitizeFileName($newFolderName ?: $folderToCopy->‪getName());
2229  if ($folderToCopy instanceof ‪Folder && $targetParentFolder instanceof ‪Folder) {
2230  $this->eventDispatcher->dispatch(
2231  new ‪BeforeFolderCopiedEvent($folderToCopy, $targetParentFolder, $sanitizedNewFolderName)
2232  );
2233  }
2234  if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && ($targetParentFolder->hasFolder($sanitizedNewFolderName) || $targetParentFolder->hasFile($sanitizedNewFolderName))) {
2235  throw new InvalidTargetFolderException(
2236  sprintf(
2237  'Cannot copy folder "%s" into target folder "%s", because there is already a folder or file with that name in the target folder!',
2238  $sanitizedNewFolderName,
2239  $targetParentFolder->‪getIdentifier()
2240  ),
2241  1422723059
2242  );
2243  }
2244  // Folder exists and we should find another name, let's find another one
2245  if ($conflictMode->equals(‪DuplicationBehavior::RENAME) && ($targetParentFolder->hasFolder($sanitizedNewFolderName) || $targetParentFolder->hasFile($sanitizedNewFolderName))) {
2246  $sanitizedNewFolderName = $this->‪getUniqueName($targetParentFolder, $sanitizedNewFolderName);
2247  }
2248  $sourceStorage = $folderToCopy->‪getStorage();
2249  // call driver method to move the file
2250  // that also updates the file object properties
2251  if ($sourceStorage === ‪$this) {
2252  $this->driver->copyFolderWithinStorage($folderToCopy->‪getIdentifier(), $targetParentFolder->‪getIdentifier(), $sanitizedNewFolderName);
2253  $returnObject = $this->‪getFolder($targetParentFolder->getSubfolder($sanitizedNewFolderName)->‪getIdentifier());
2254  } else {
2255  $this->‪copyFolderBetweenStorages($folderToCopy, $targetParentFolder, $sanitizedNewFolderName);
2256  }
2257  if ($folderToCopy instanceof ‪Folder && $targetParentFolder instanceof ‪Folder) {
2258  $this->eventDispatcher->dispatch(
2259  new ‪AfterFolderCopiedEvent($folderToCopy, $targetParentFolder, $returnObject)
2260  );
2261  }
2262  return $returnObject;
2263  }
2264 
2271  protected function ‪copyFolderBetweenStorages(‪FolderInterface $folderToCopy, ‪FolderInterface $targetParentFolder, $newFolderName)
2272  {
2273  throw new ‪NotImplementedMethodException('Not yet implemented.', 1476046386);
2274  }
2275 
2285  public function ‪renameFolder($folderObject, $newName)
2286  {
2287  // Renaming the folder should check if the parent folder is writable
2288  // We cannot do this however because we cannot extract the parent folder from a folder currently
2289  if (!$this->‪checkFolderActionPermission('rename', $folderObject)) {
2290  throw new ‪InsufficientUserPermissionsException('You are not allowed to rename the folder "' . $folderObject->getIdentifier() . '\'', 1357811441);
2291  }
2292 
2293  $sanitizedNewName = $this->driver->sanitizeFileName($newName);
2294  if ($this->driver->folderExistsInFolder($sanitizedNewName, $folderObject->getIdentifier())) {
2295  throw new \InvalidArgumentException('The folder ' . $sanitizedNewName . ' already exists in folder ' . $folderObject->getIdentifier(), 1325418870);
2296  }
2297  $this->eventDispatcher->dispatch(
2298  new BeforeFolderRenamedEvent($folderObject, $sanitizedNewName)
2299  );
2300  $fileObjects = $this->‪getAllFileObjectsInFolder($folderObject);
2301  $fileMappings = $this->driver->renameFolder($folderObject->getIdentifier(), $sanitizedNewName);
2302  // Update the identifier of all file objects
2303  foreach ($fileObjects as $oldIdentifier => $fileObject) {
2304  $newIdentifier = $fileMappings[$oldIdentifier];
2305  $fileObject->updateProperties(['identifier' => $newIdentifier]);
2306  $this->‪getIndexer()->‪updateIndexEntry($fileObject);
2307  }
2308  $returnObject = $this->‪getFolder($fileMappings[$folderObject->getIdentifier()]);
2309 
2310  $this->eventDispatcher->dispatch(
2311  new AfterFolderRenamedEvent($returnObject, $folderObject)
2312  );
2313  return $returnObject;
2314  }
2315 
2328  public function ‪deleteFolder($folderObject, $deleteRecursively = false)
2329  {
2330  $isEmpty = $this->driver->isFolderEmpty($folderObject->getIdentifier());
2331  $this->‪assureFolderDeletePermission($folderObject, $deleteRecursively && !$isEmpty);
2332  if (!$isEmpty && !$deleteRecursively) {
2333  throw new \RuntimeException('Could not delete folder "' . $folderObject->getIdentifier() . '" because it is not empty.', 1325952534);
2334  }
2335 
2336  $this->eventDispatcher->dispatch(
2337  new BeforeFolderDeletedEvent($folderObject)
2338  );
2339 
2340  foreach ($this->‪getFilesInFolder($folderObject, 0, 0, false, $deleteRecursively) as $file) {
2341  $this->‪deleteFile($file);
2342  }
2343 
2344  $result = $this->driver->deleteFolder($folderObject->getIdentifier(), $deleteRecursively);
2345 
2346  $this->eventDispatcher->dispatch(
2347  new ‪AfterFolderDeletedEvent($folderObject, $result)
2348  );
2349  return $result;
2350  }
2351 
2361  public function ‪getFolderInFolder($folderName, ‪Folder $parentFolder, $returnInaccessibleFolderObject = false)
2362  {
2363  $folderIdentifier = $this->driver->getFolderInFolder($folderName, $parentFolder->‪getIdentifier());
2364  return $this->‪getFolder($folderIdentifier, $returnInaccessibleFolderObject);
2365  }
2366 
2380  public function getFoldersInFolder(‪Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
2381  {
2382  $filters = $useFilters == true ? $this->‪getFileAndFolderNameFilters() : [];
2383 
2384  ‪$folderIdentifiers = $this->driver->getFoldersInFolder($folder->‪getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev);
2386  // Exclude processing folders
2387  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
2388  $processingIdentifier = ‪$processingFolder->‪getIdentifier();
2389  if (isset(‪$folderIdentifiers[$processingIdentifier])) {
2390  unset(‪$folderIdentifiers[$processingIdentifier]);
2391  }
2392  }
2393 
2395  foreach (‪$folderIdentifiers as $folderIdentifier) {
2396  // The folder identifier can also be an int-like string, resulting in int array keys.
2397  ‪$folders[$folderIdentifier] = $this->‪getFolder($folderIdentifier, true);
2398  }
2399  return ‪$folders;
2400  }
2401 
2408  public function ‪countFoldersInFolder(Folder $folder, $useFilters = true, $recursive = false)
2409  {
2410  $this->‪assureFolderReadPermission($folder);
2411  $filters = $useFilters ? $this->‪getFileAndFolderNameFilters() : [];
2412  return $this->driver->countFoldersInFolder($folder->getIdentifier(), $recursive, $filters);
2413  }
2414 
2421  public function ‪hasFolder(‪$identifier)
2422  {
2424  return $this->driver->folderExists(‪$identifier);
2425  }
2426 
2433  public function ‪hasFolderInFolder($folderName, Folder $folder)
2434  {
2435  $this->‪assureFolderReadPermission($folder);
2436  return $this->driver->folderExistsInFolder($folderName, $folder->getIdentifier());
2437  }
2452  public function ‪createFolder($folderName, ‪Folder $parentFolder = null)
2453  {
2454  if ($parentFolder === null) {
2455  $parentFolder = $this->‪getRootLevelFolder();
2456  } elseif (!$this->driver->folderExists($parentFolder->getIdentifier())) {
2457  throw new \InvalidArgumentException('Parent folder "' . $parentFolder->getIdentifier() . '" does not exist.', 1325689164);
2458  }
2459  if (!$this->‪checkFolderActionPermission('add', $parentFolder)) {
2460  throw new ‪InsufficientFolderWritePermissionsException('You are not allowed to create directories in the folder "' . $parentFolder->getIdentifier() . '"', 1323059807);
2461  }
2462  if ($this->driver->folderExistsInFolder($folderName, $parentFolder->getIdentifier())) {
2463  throw new ‪ExistingTargetFolderException('Folder "' . $folderName . '" already exists.', 1423347324);
2464  }
2465 
2466  $this->eventDispatcher->dispatch(
2467  new ‪BeforeFolderAddedEvent($parentFolder, $folderName)
2468  );
2469 
2470  $newFolder = $this->‪getDriver()->‪createFolder($folderName, $parentFolder->getIdentifier(), true);
2471  $newFolder = $this->‪getFolder($newFolder);
2472 
2473  $this->eventDispatcher->dispatch(
2474  new ‪AfterFolderAddedEvent($newFolder)
2475  );
2476 
2477  return $newFolder;
2478  }
2479 
2485  public function ‪getFolderInfo(‪Folder $folder)
2486  {
2487  return $this->driver->getFolderInfoByIdentifier($folder->‪getIdentifier());
2488  }
2489 
2495  public function ‪getDefaultFolder()
2496  {
2497  return $this->‪getFolder($this->driver->getDefaultFolder());
2498  }
2499 
2508  public function ‪getFolder(‪$identifier, $returnInaccessibleFolderObject = false)
2509  {
2510  $data = $this->driver->getFolderInfoByIdentifier(‪$identifier);
2511  $folder = $this->‪createFolderObject($data['identifier'] ?? '', $data['name'] ?? '');
2512 
2513  try {
2514  $this->‪assureFolderReadPermission($folder);
2515  } catch (InsufficientFolderAccessPermissionsException $e) {
2516  $folder = null;
2517  if ($returnInaccessibleFolderObject) {
2518  // if parent folder is readable return inaccessible folder object
2519  $parentPermissions = $this->driver->getPermissions($this->driver->getParentFolderIdentifierOfIdentifier(‪$identifier));
2520  if ($parentPermissions['r']) {
2521  $folder = GeneralUtility::makeInstance(
2522  InaccessibleFolder::class,
2523  ‪$this,
2524  $data['identifier'],
2525  $data['name']
2526  );
2527  }
2528  }
2530  if ($folder === null) {
2531  throw $e;
2532  }
2533  }
2534  return $folder;
2535  }
2536 
2544  {
2545  $inProcessingFolder = false;
2546  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
2548  $inProcessingFolder = true;
2549  break;
2550  }
2551  }
2552  return $inProcessingFolder;
2553  }
2554 
2561  public function ‪isWithinFolder(Folder $folder, ResourceInterface $resource)
2562  {
2563  if ($folder->getStorage() !== ‪$this) {
2564  throw new \InvalidArgumentException('Given folder "' . $folder->getIdentifier() . '" is not part of this storage!', 1422709241);
2565  }
2566  if ($folder->getStorage() !== $resource->getStorage()) {
2567  return false;
2568  }
2569  return $this->driver->isWithin($folder->getIdentifier(), $resource->getIdentifier());
2570  }
2571 
2580  public function ‪getRootLevelFolder($respectFileMounts = true)
2581  {
2582  if ($respectFileMounts && !empty($this->fileMounts)) {
2583  $mount = reset($this->fileMounts);
2584  return $mount['folder'];
2585  }
2586  return $this->‪createFolderObject($this->driver->getRootLevelFolder(), '');
2587  }
2588 
2603  protected function ‪getUniqueName(FolderInterface $folder, $theFile, $dontCheckForUnique = false)
2604  {
2605  $maxNumber = 99;
2606  // Fetches info about path, name, extension of $theFile
2607  $origFileInfo = ‪PathUtility::pathinfo($theFile);
2608  // Check if the file exists and if not - return the fileName...
2609  // The destinations file
2610  $theDestFile = $origFileInfo['basename'];
2611  // If the file does NOT exist we return this fileName
2612  if ($dontCheckForUnique || (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier()) && !‪$this->driver->folderExistsInFolder($theDestFile, $folder->getIdentifier()))) {
2613  return $theDestFile;
2614  }
2615  // Well the fileName in its pure form existed. Now we try to append
2616  // numbers / unique-strings and see if we can find an available fileName
2617  // This removes _xx if appended to the file
2618  $theTempFileBody = preg_replace('/_[0-9][0-9]$/', '', $origFileInfo['filename']);
2619  $theOrigExt = ($origFileInfo['extension'] ?? '') ? '.' . $origFileInfo['extension'] : '';
2620  for ($a = 1; $a <= $maxNumber + 1; $a++) {
2621  // First we try to append numbers
2622  if ($a <= $maxNumber) {
2623  $insert = '_' . sprintf('%02d', $a);
2624  } else {
2625  $insert = '_' . substr(md5(‪StringUtility::getUniqueId()), 0, 6);
2626  }
2627  $theTestFile = $theTempFileBody . $insert . $theOrigExt;
2628  // The destinations file
2629  $theDestFile = $theTestFile;
2630  // If the file does NOT exist we return this fileName
2631  if (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier()) && !‪$this->driver->folderExistsInFolder($theDestFile, $folder->getIdentifier())) {
2632  return $theDestFile;
2633  }
2634  }
2635  throw new \RuntimeException('Last possible name "' . $theDestFile . '" is already taken.', 1325194291);
2636  }
2637 
2641  protected function ‪getFileFactory()
2642  {
2643  return GeneralUtility::makeInstance(ResourceFactory::class);
2644  }
2645 
2649  protected function ‪getFileIndexRepository()
2650  {
2651  return GeneralUtility::makeInstance(FileIndexRepository::class);
2652  }
2653 
2657  protected function ‪getFileProcessingService()
2658  {
2659  if (!$this->fileProcessingService) {
2660  $this->fileProcessingService = GeneralUtility::makeInstance(FileProcessingService::class, ‪$this, $this->driver, $this->eventDispatcher);
2661  }
2663  }
2664 
2671  public function ‪getRole(‪FolderInterface $folder)
2672  {
2673  $folderRole = ‪FolderInterface::ROLE_DEFAULT;
2674  ‪$identifier = $folder->‪getIdentifier();
2675  if (method_exists($this->driver, 'getRole')) {
2676  $folderRole = $this->driver->getRole($folder->‪getIdentifier());
2677  }
2678  if (isset($this->fileMounts[‪$identifier])) {
2679  $folderRole = ‪FolderInterface::ROLE_MOUNT;
2680 
2681  if (!empty($this->fileMounts[‪$identifier]['read_only'])) {
2683  }
2684  if ($this->fileMounts[‪$identifier]['user_mount'] ?? false) {
2686  }
2687  }
2688  if ($folder instanceof ‪Folder && $this->‪isProcessingFolder($folder)) {
2690  }
2691 
2692  return $folderRole;
2693  }
2694 
2702  public function ‪getProcessingFolder(File $file = null)
2703  {
2704  // If a file is given, make sure to return the processing folder of the correct storage
2705  if ($file !== null && $file->getStorage()->getUid() !== ‪$this->getUid()) {
2706  return $file->‪getStorage()->‪getProcessingFolder($file);
2707  }
2708  if (!isset($this->processingFolder)) {
2710  if (!empty($this->storageRecord['processingfolder'])) {
2711  ‪$processingFolder = $this->storageRecord['processingfolder'];
2712  }
2713  try {
2714  if (str_contains(‪$processingFolder, ':')) {
2715  [$storageUid, $processingFolderIdentifier] = explode(':', ‪$processingFolder, 2);
2716  $storage = GeneralUtility::makeInstance(StorageRepository::class)->findByUid((int)$storageUid);
2717  if ($storage->hasFolder($processingFolderIdentifier)) {
2718  $this->processingFolder = $storage->getFolder($processingFolderIdentifier);
2719  } else {
2720  $rootFolder = $storage->getRootLevelFolder(false);
2721  $currentEvaluatePermissions = $storage->getEvaluatePermissions();
2722  $storage->setEvaluatePermissions(false);
2723  $this->processingFolder = $storage->createFolder(
2724  ltrim($processingFolderIdentifier, '/'),
2725  $rootFolder
2726  );
2727  $storage->setEvaluatePermissions($currentEvaluatePermissions);
2728  }
2729  } else {
2730  if ($this->driver->folderExists(‪$processingFolder) === false) {
2731  $rootFolder = $this->‪getRootLevelFolder(false);
2732  try {
2733  $currentEvaluatePermissions = ‪$this->evaluatePermissions;
2734  $this->evaluatePermissions = false;
2735  $this->processingFolder = $this->‪createFolder(
2736  $processingFolder,
2737  $rootFolder
2738  );
2739  $this->evaluatePermissions = $currentEvaluatePermissions;
2740  } catch (\InvalidArgumentException $e) {
2741  $this->processingFolder = GeneralUtility::makeInstance(
2742  InaccessibleFolder::class,
2743  ‪$this,
2746  );
2747  }
2748  } else {
2749  $data = $this->driver->getFolderInfoByIdentifier(‪$processingFolder);
2750  $this->processingFolder = $this->‪createFolderObject($data['identifier'], $data['name']);
2751  }
2752  }
2753  } catch (InsufficientFolderWritePermissionsException|ResourcePermissionsUnavailableException $e) {
2754  $this->processingFolder = GeneralUtility::makeInstance(
2755  InaccessibleFolder::class,
2756  ‪$this,
2759  );
2760  }
2761  }
2762 
2764  if (!empty($file)) {
2766  }
2767  return ‪$processingFolder;
2768  }
2769 
2777  protected function ‪getNestedProcessingFolder(File $file, Folder $rootProcessingFolder)
2778  {
2779  ‪$processingFolder = $rootProcessingFolder;
2780  $nestedFolderNames = $this->‪getNamesForNestedProcessingFolder(
2781  $file->getIdentifier(),
2782  self::PROCESSING_FOLDER_LEVELS
2783  );
2784 
2785  try {
2786  foreach ($nestedFolderNames as $folderName) {
2787  if (‪$processingFolder->‪hasFolder($folderName)) {
2789  } else {
2790  $currentEvaluatePermissions = ‪$processingFolder->‪getStorage()->‪getEvaluatePermissions();
2793  ‪$processingFolder->‪getStorage()->‪setEvaluatePermissions($currentEvaluatePermissions);
2794  }
2795  }
2796  } catch (FolderDoesNotExistException $e) {
2797  }
2798 
2799  return ‪$processingFolder;
2800  }
2801 
2809  protected function ‪getNamesForNestedProcessingFolder($fileIdentifier, $levels)
2810  {
2811  $names = [];
2812  if ($levels === 0) {
2813  return $names;
2814  }
2815  $hash = md5($fileIdentifier);
2816  for ($i = 1; $i <= $levels; $i++) {
2817  $names[] = substr($hash, $i, 1);
2818  }
2819  return $names;
2820  }
2821 
2827  public function ‪getDriverType()
2828  {
2829  return $this->storageRecord['driver'];
2830  }
2837  protected function ‪getIndexer()
2838  {
2839  return GeneralUtility::makeInstance(Indexer::class, ‪$this);
2840  }
2841 
2845  public function ‪setDefault(‪$isDefault)
2846  {
2847  $this->‪isDefault = (bool)‪$isDefault;
2848  }
2853  public function ‪isDefault()
2854  {
2855  return ‪$this->isDefault;
2856  }
2857 
2859  {
2860  return GeneralUtility::makeInstance(ResourceFactory::class);
2861  }
2862 
2863  protected function ‪getBackendUser(): BackendUserAuthentication
2864  {
2865  return ‪$GLOBALS['BE_USER'];
2866  }
2867 
2879  protected function ‪getNearestRecyclerFolder(‪FileInterface $file)
2880  {
2881  if ($file instanceof ‪ProcessedFile) {
2882  return null;
2883  }
2884  // if the storage is not browsable we cannot fetch the parent folder of the file so no recycler handling is possible
2885  if (!$this->‪isBrowsable()) {
2886  return null;
2887  }
2888 
2889  $recyclerFolder = null;
2890  $folder = $file->‪getParentFolder();
2891 
2892  do {
2893  if ($folder->getRole() === ‪FolderInterface::ROLE_RECYCLER) {
2894  break;
2895  }
2896 
2897  foreach ($folder->getSubfolders() as $subFolder) {
2898  if ($subFolder->getRole() === ‪FolderInterface::ROLE_RECYCLER) {
2899  $recyclerFolder = $subFolder;
2900  break;
2901  }
2902  }
2903 
2904  $parentFolder = $folder->‪getParentFolder();
2905  $isFolderLoop = $folder->‪getIdentifier() === $parentFolder->getIdentifier();
2906  $folder = $parentFolder;
2907  } while ($recyclerFolder === null && !$isFolderLoop);
2908 
2909  return $recyclerFolder;
2910  }
2911 
2919  protected function ‪createFolderObject(string ‪$identifier, string $name)
2920  {
2921  return GeneralUtility::makeInstance(Folder::class, ‪$this, ‪$identifier, $name);
2922  }
2923 }
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderRenamedEvent
Definition: BeforeFolderRenamedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileProcessingService
‪Service FileProcessingService getFileProcessingService()
Definition: ResourceStorage.php:2643
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileAndFolderNameFilters
‪array $fileAndFolderNameFilters
Definition: ResourceStorage.php:207
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:916
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileByIdentifier
‪File ProcessedFile null getFileByIdentifier(string $fileIdentifier)
Definition: ResourceStorage.php:1420
‪TYPO3\CMS\Core\Resource\ResourceStorage\getBackendUser
‪getBackendUser()
Definition: ResourceStorage.php:2849
‪TYPO3\CMS\Core\Resource\Search\Result\EmptyFileSearchResult
Definition: EmptyFileSearchResult.php:24
‪TYPO3\CMS\Core\Utility\PathUtility\getCanonicalPath
‪static string getCanonicalPath(string $path)
Definition: PathUtility.php:364
‪TYPO3\CMS\Core\Resource\Event\BeforeFolderDeletedEvent
Definition: BeforeFolderDeletedEvent.php:28
‪TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile
‪File getOriginalFile()
Definition: ProcessedFile.php:300
‪TYPO3\CMS\Core\Resource\ProcessedFileRepository
Definition: ProcessedFileRepository.php:31
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileWritePermissionsException
Definition: InsufficientFileWritePermissionsException.php:22
‪TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException
Definition: InsufficientUserPermissionsException.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\renameFolder
‪Folder renameFolder($folderObject, $newName)
Definition: ResourceStorage.php:2271
‪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:2314
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository
Definition: FileIndexRepository.php:42
‪TYPO3\CMS\Core\Resource\Event\BeforeFileCreatedEvent
Definition: BeforeFileCreatedEvent.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileAndFolderNameFilter
‪addFileAndFolderNameFilter($filter)
Definition: ResourceStorage.php:1511
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\resetFileAndFolderNameFiltersToDefault
‪resetFileAndFolderNameFiltersToDefault()
Definition: ResourceStorage.php:1471
‪TYPO3\CMS\Core\Resource\ResourceStorage\countFilesInFolder
‪int countFilesInFolder(Folder $folder, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1598
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry
Definition: OnlineMediaHelperRegistry.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInfo
‪array getFileInfo(FileInterface $fileObject)
Definition: ResourceStorage.php:1443
‪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:521
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUid
‪int getUid()
Definition: ResourceStorage.php:328
‪TYPO3\CMS\Core\Resource\ResourceStorage\setUserPermissions
‪setUserPermissions(array $userPermissions)
Definition: ResourceStorage.php:656
‪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:1455
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface\createFolder
‪string createFolder($newFolderName, $parentFolderIdentifier='', $recursive=false)
‪TYPO3\CMS\Core\Resource\ResourceStorage\getEvaluatePermissions
‪bool getEvaluatePermissions()
Definition: ResourceStorage.php:648
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderInFolder
‪Folder InaccessibleFolder getFolderInFolder($folderName, Folder $parentFolder, $returnInaccessibleFolderObject=false)
Definition: ResourceStorage.php:2347
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\CANCEL
‪const CANCEL
Definition: DuplicationBehavior.php:46
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileReplacePermissions
‪assureFileReplacePermissions(FileInterface $file)
Definition: ResourceStorage.php:918
‪TYPO3\CMS\Core\Resource\ResourceStorage\PROCESSING_FOLDER_LEVELS
‪const PROCESSING_FOLDER_LEVELS
Definition: ResourceStorage.php:212
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileReadPermissionsException
Definition: InsufficientFileReadPermissionsException.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDefaultFolder
‪Folder getDefaultFolder()
Definition: ResourceStorage.php:2481
‪TYPO3\CMS\Core\Resource\FileInterface
Definition: FileInterface.php:22
‪TYPO3\CMS\Core\Resource\AbstractFile\getForLocalProcessing
‪string getForLocalProcessing($writable=true)
Definition: AbstractFile.php:580
‪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:2147
‪TYPO3\CMS\Core\Resource\Folder\getParentFolder
‪FolderInterface getParentFolder()
Definition: Folder.php:541
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDriverType
‪string getDriverType()
Definition: ResourceStorage.php:2813
‪TYPO3\CMS\Core\Resource\Folder\hasFile
‪bool hasFile($name)
Definition: Folder.php:394
‪TYPO3\CMS\Core\Resource\ResourceStorage\searchFiles
‪searchFiles(FileSearchDemand $searchDemand, Folder $folder=null, bool $useFilters=true)
Definition: ResourceStorage.php:420
‪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:1376
‪TYPO3\CMS\Core\Resource\ResourceStorage\$storageRecord
‪array $storageRecord
Definition: ResourceStorage.php:138
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_DEFAULT
‪const ROLE_DEFAULT
Definition: FolderInterface.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileExtensionPermission
‪bool checkFileExtensionPermission($fileName)
Definition: ResourceStorage.php:814
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFilesInFolder
‪File[] getFilesInFolder(Folder $folder, $start=0, $maxNumberOfItems=0, $useFilters=true, $recursive=false, $sort='', $sortRev=false)
Definition: ResourceStorage.php:1552
‪TYPO3\CMS\Core\Resource\ResourceStorage\getStorageRecord
‪array getStorageRecord()
Definition: ResourceStorage.php:287
‪TYPO3
‪TYPO3\CMS\Core\Resource\Event\AfterFolderMovedEvent
Definition: AfterFolderMovedEvent.php:29
‪TYPO3\CMS\Core\Resource\Event\BeforeFileDeletedEvent
Definition: BeforeFileDeletedEvent.php:28
‪TYPO3\CMS\Core\Resource\Index\Indexer
Definition: Indexer.php:34
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessingFolder
‪Folder getProcessingFolder(File $file=null)
Definition: ResourceStorage.php:2688
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileFactory
‪ResourceFactory getFileFactory()
Definition: ResourceStorage.php:2627
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileMount
‪addFileMount($folderIdentifier, $additionalData=[])
Definition: ResourceStorage.php:541
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static getPublicPath()
Definition: Environment.php:187
‪TYPO3\CMS\Core\Resource\ResourceStorage\getResourceFactoryInstance
‪getResourceFactoryInstance()
Definition: ResourceStorage.php:2844
‪TYPO3\CMS\Core\Registry
Definition: Registry.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\$configuration
‪array $configuration
Definition: ResourceStorage.php:144
‪TYPO3\CMS\Core\Resource\ResourceStorage\copyFolderBetweenStorages
‪copyFolderBetweenStorages(FolderInterface $folderToCopy, FolderInterface $targetParentFolder, $newFolderName)
Definition: ResourceStorage.php:2257
‪TYPO3\CMS\Core\Resource\Event\AfterFolderCopiedEvent
Definition: AfterFolderCopiedEvent.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolder
‪Folder InaccessibleFolder getFolder($identifier, $returnInaccessibleFolderObject=false)
Definition: ResourceStorage.php:2494
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderIdentifierFromFileIdentifier
‪string getFolderIdentifierFromFileIdentifier($fileIdentifier)
Definition: ResourceStorage.php:1521
‪TYPO3\CMS\Core\Resource\ResourceStorage\replaceFile
‪FileInterface replaceFile(FileInterface $file, $localFilePath)
Definition: ResourceStorage.php:2047
‪TYPO3\CMS\Core\Resource\ResourceStorage\renameFile
‪FileInterface renameFile($file, $targetFileName, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:1995
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface
Definition: DriverInterface.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFile
‪FileInterface getFile($identifier)
Definition: ResourceStorage.php:1404
‪TYPO3\CMS\Core\Resource\Event\BeforeFileRenamedEvent
Definition: BeforeFileRenamedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDriver
‪Driver DriverInterface getDriver()
Definition: ResourceStorage.php:308
‪TYPO3\CMS\Core\Resource\ResourceStorage\$isOnline
‪bool $isOnline
Definition: ResourceStorage.php:197
‪TYPO3\CMS\Core\Resource\Event\AfterFileCreatedEvent
Definition: AfterFileCreatedEvent.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFileByIdentifier
‪string hashFileByIdentifier($fileIdentifier, $hash)
Definition: ResourceStorage.php:1292
‪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:1504
‪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:43
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasCapability
‪bool hasCapability($capability)
Definition: ResourceStorage.php:366
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessingFolders
‪Folder[] getProcessingFolders()
Definition: ResourceStorage.php:1637
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileIdentifiersInFolder
‪array getFileIdentifiersInFolder($folderIdentifier, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1586
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository\findByFolder
‪array null findByFolder(Folder $folder)
Definition: FileIndexRepository.php:172
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderInfo
‪array getFolderInfo(Folder $folder)
Definition: ResourceStorage.php:2471
‪TYPO3\CMS\Core\Resource\Index\Indexer\updateIndexEntry
‪updateIndexEntry(File $fileObject)
Definition: Indexer.php:90
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessedFileRepository
‪getProcessedFileRepository()
Definition: ResourceStorage.php:1432
‪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:2407
‪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:594
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileContents
‪string getFileContents($file)
Definition: ResourceStorage.php:1699
‪TYPO3\CMS\Core\Resource\ResourceStorage\isDefault
‪bool isDefault()
Definition: ResourceStorage.php:2839
‪TYPO3\CMS\Core\Resource\ResourceStorage\isProcessingFolder
‪bool isProcessingFolder(Folder $folder)
Definition: ResourceStorage.php:1667
‪TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException
Definition: IllegalFileExtensionException.php:24
‪TYPO3\CMS\Core\Utility\PathUtility\basename
‪static basename(string $path)
Definition: PathUtility.php:219
‪TYPO3\CMS\Core\Resource\ResourceStorage\addUploadedFile
‪FileInterface addUploadedFile(array|UploadedFile $uploadedFileData, Folder $targetFolder=null, $targetFileName=null, $conflictMode=DuplicationBehavior::CANCEL)
Definition: ResourceStorage.php:2075
‪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:1532
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFile
‪bool hasFile($identifier)
Definition: ResourceStorage.php:1623
‪TYPO3\CMS\Core\Resource\ResourceStorage\setFileContents
‪int setFileContents(AbstractFile $file, $contents)
Definition: ResourceStorage.php:1772
‪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:2566
‪TYPO3\CMS\Core\Resource\Event\AfterFolderRenamedEvent
Definition: AfterFolderRenamedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\$folderIdentifiers
‪$folderIdentifiers
Definition: ResourceStorage.php:2370
‪TYPO3\CMS\Core\Resource\Folder\getName
‪string getName()
Definition: Folder.php:93
‪TYPO3\CMS\Core\Resource\Exception\UploadException
Definition: UploadException.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\$capabilities
‪int $capabilities
Definition: ResourceStorage.php:177
‪TYPO3\CMS\Core\Service\FlexFormService
Definition: FlexFormService.php:25
‪TYPO3\CMS\Core\Resource\Event\GeneratePublicUrlForResourceEvent
Definition: GeneratePublicUrlForResourceEvent.php:31
‪TYPO3\CMS\Core\Resource\ResourceStorage\$processingFolder
‪Folder null $processingFolder
Definition: ResourceStorage.php:185
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath(string $targetPath, bool $prefixWithSitePath=true)
Definition: PathUtility.php:52
‪TYPO3\CMS\Core\Resource\Folder\getStorage
‪ResourceStorage getStorage()
Definition: Folder.php:148
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFileIdentifier
‪string hashFileIdentifier($file)
Definition: ResourceStorage.php:1309
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFile
‪FileInterface addFile($localFilePath, Folder $targetFolder, $targetFileName='', $conflictMode=DuplicationBehavior::RENAME, $removeOriginal=true)
Definition: ResourceStorage.php:1211
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Webhooks\Message\$publicUrl
‪identifier readonly string readonly string $publicUrl
Definition: FileUpdatedMessage.php:36
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileAndFolderNameFilters
‪array< string|int, getFoldersInFolder(Folder $folder, $start=0, $maxNumberOfItems=0, $useFilters=true, $recursive=false, $sort='', $sortRev=false) { $filters=$useFilters==true ? $this-> getFileAndFolderNameFilters()
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileReadPermission
‪assureFileReadPermission(FileInterface $file)
Definition: ResourceStorage.php:878
‪TYPO3\CMS\Core\Resource\ResourceStorage\$driver
‪Driver DriverInterface $driver
Definition: ResourceStorage.php:132
‪TYPO3\CMS\Core\Resource\ResourceStorage\isOnline
‪bool isOnline()
Definition: ResourceStorage.php:451
‪TYPO3\CMS\Core\Resource\InaccessibleFolder
Definition: InaccessibleFolder.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFolderActionPermission
‪bool checkFolderActionPermission($action, Folder $folder=null)
Definition: ResourceStorage.php:763
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\setEvaluatePermissions
‪setEvaluatePermissions($evaluatePermissions)
Definition: ResourceStorage.php:637
‪TYPO3\CMS\Core\Resource\ResourceStorage\streamFile
‪streamFile(FileInterface $file, bool $asDownload=false, string $alternativeFilename=null, string $overrideMimeType=null)
Definition: ResourceStorage.php:1712
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFile
‪FileInterface moveFile($file, $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:1928
‪TYPO3\CMS\Core\Resource\AbstractFile
Definition: AbstractFile.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\getRole
‪string getRole(FolderInterface $folder)
Definition: ResourceStorage.php:2657
‪TYPO3\CMS\Core\Resource\ResourceStorage\markAsPermanentlyOffline
‪markAsPermanentlyOffline()
Definition: ResourceStorage.php:499
‪TYPO3\CMS\Core\Resource\Exception\InvalidConfigurationException
Definition: InvalidConfigurationException.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\getAllFileObjectsInFolder
‪File[] getAllFileObjectsInFolder(Folder $folder)
Definition: ResourceStorage.php:2115
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileMovePermissions
‪assureFileMovePermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
Definition: ResourceStorage.php:1024
‪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:969
‪TYPO3\CMS\Core\Resource\ResourceStorage\__construct
‪__construct(DriverInterface $driver, array $storageRecord, EventDispatcherInterface $eventDispatcher=null)
Definition: ResourceStorage.php:220
‪TYPO3\CMS\Core\Resource\ResourceStorage\getCapabilities
‪int getCapabilities()
Definition: ResourceStorage.php:355
‪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:1392
‪TYPO3\CMS\Core\Resource\AbstractFile\getPublicUrl
‪string null getPublicUrl()
Definition: AbstractFile.php:562
‪TYPO3\CMS\Core\Resource\ResourceStorage\isBrowsable
‪bool isBrowsable()
Definition: ResourceStorage.php:400
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFolder
‪Folder createFolder($folderName, Folder $parentFolder=null)
Definition: ResourceStorage.php:2438
‪TYPO3\CMS\Core\Resource\Folder\createFolder
‪Folder createFolder($folderName)
Definition: Folder.php:357
‪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\ResourceStorage\createFile
‪FileInterface createFile($fileName, Folder $targetFolderObject)
Definition: ResourceStorage.php:1802
‪TYPO3\CMS\Core\Resource\Event\AfterFileRenamedEvent
Definition: AfterFileRenamedEvent.php:27
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:24
‪TYPO3\CMS\Core\Http\UploadedFile\getClientFilename
‪string null getClientFilename()
Definition: UploadedFile.php:252
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinFolder
‪bool isWithinFolder(Folder $folder, ResourceInterface $resource)
Definition: ResourceStorage.php:2547
‪TYPO3\CMS\Core\Resource\Event\AfterFileContentsSetEvent
Definition: AfterFileContentsSetEvent.php:28
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\RENAME
‪const RENAME
Definition: DuplicationBehavior.php:32
‪TYPO3\CMS\Core\Resource\Folder\checkActionPermission
‪bool checkActionPermission($action)
Definition: Folder.php:429
‪TYPO3\CMS\Core\Resource\ResourceStorage\autoExtractMetadataEnabled
‪bool autoExtractMetadataEnabled()
Definition: ResourceStorage.php:487
‪TYPO3\CMS\Core\Utility\GeneralUtility\hmac
‪static string hmac($input, $additionalSecret='')
Definition: GeneralUtility.php:584
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileDeletePermissions
‪assureFileDeletePermissions(FileInterface $file)
Definition: ResourceStorage.php:937
‪TYPO3\CMS\Core\Resource\ResourceStorage\getConfiguration
‪array getConfiguration()
Definition: ResourceStorage.php:269
‪TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: AbstractFile.php:451
‪TYPO3\CMS\Core\Resource\Event\AfterFileCopiedEvent
Definition: AfterFileCopiedEvent.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasChildren
‪bool hasChildren()
Definition: ResourceStorage.php:338
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:66
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileMounts
‪array getFileMounts()
Definition: ResourceStorage.php:581
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_PROCESSING
‪const ROLE_PROCESSING
Definition: FolderInterface.php:28
‪TYPO3\CMS\Core\Resource\Folder\getRole
‪string getRole()
Definition: Folder.php:526
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinProcessingFolder
‪bool isWithinProcessingFolder($identifier)
Definition: ResourceStorage.php:2529
‪TYPO3\CMS\Core\Resource\Index\Indexer\createIndexEntry
‪createIndexEntry($identifier)
Definition: Indexer.php:64
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasHierarchicalIdentifiers
‪hasHierarchicalIdentifiers()
Definition: ResourceStorage.php:408
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFolderBetweenStorages
‪moveFolderBetweenStorages(Folder $folderToMove, Folder $targetParentFolder, $newFolderName)
Definition: ResourceStorage.php:2194
‪TYPO3\CMS\Core\Resource\ResourceStorage\$eventDispatcher
‪EventDispatcherInterface $eventDispatcher
Definition: ResourceStorage.php:181
‪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:216
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderCopyPermissions
‪assureFolderCopyPermissions(FolderInterface $folderToCopy, FolderInterface $targetParentFolder)
Definition: ResourceStorage.php:1116
‪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:603
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileProcessingService
‪Service FileProcessingService $fileProcessingService
Definition: ResourceStorage.php:148
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNamesForNestedProcessingFolder
‪string[] getNamesForNestedProcessingFolder($fileIdentifier, $levels)
Definition: ResourceStorage.php:2795
‪TYPO3\CMS\Core\Resource\ResourceStorage\$folders
‪foreach($folderIdentifiers as $folderIdentifier) return $folders
Definition: ResourceStorage.php:2381
‪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:1182
‪TYPO3\CMS\Core\Resource\Folder\getSubfolder
‪Folder getSubfolder($name)
Definition: Folder.php:268
‪TYPO3\CMS\Core\Resource\ResourceInterface\getName
‪string getName()
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFolderObject
‪Folder createFolderObject(string $identifier, string $name)
Definition: ResourceStorage.php:2905
‪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:201
‪TYPO3\CMS\Core\Resource
Definition: generateMimeTypes.php:52
‪TYPO3\CMS\Core\Resource\ProcessedFile
Definition: ProcessedFile.php:45
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_BROWSABLE
‪const CAPABILITY_BROWSABLE
Definition: ResourceStorageInterface.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\$this
‪return $this
Definition: ResourceStorage.php:1505
‪TYPO3\CMS\Core\Resource\ResourceStorage\$processingFolders
‪Folder[] $processingFolders
Definition: ResourceStorage.php:191
‪TYPO3\CMS\Core\Resource\Event\BeforeFileAddedEvent
Definition: BeforeFileAddedEvent.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderReadPermission
‪assureFolderReadPermission(Folder $folder=null)
Definition: ResourceStorage.php:826
‪TYPO3\CMS\Core\Resource\ResourceStorage\usesCaseSensitiveIdentifiers
‪bool usesCaseSensitiveIdentifiers()
Definition: ResourceStorage.php:441
‪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:1685
‪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:439
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileCopyPermissions
‪assureFileCopyPermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
Definition: ResourceStorage.php:1084
‪TYPO3\CMS\Core\Resource\ResourceStorage\$evaluatePermissions
‪bool $evaluatePermissions
Definition: ResourceStorage.php:157
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:127
‪TYPO3\CMS\Core\Resource\ResourceStorage\setDriver
‪ResourceStorage setDriver(DriverInterface $driver)
Definition: ResourceStorage.php:297
‪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:1738
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderMovePermissions
‪assureFolderMovePermissions(FolderInterface $folderToMove, FolderInterface $targetParentFolder)
Definition: ResourceStorage.php:1150
‪TYPO3\CMS\Core\Resource\ResourceStorage\isPublic
‪bool isPublic()
Definition: ResourceStorage.php:379
‪TYPO3\CMS\Core\Log\LogManager
Definition: LogManager.php:33
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪if
‪if(PHP_SAPI !=='cli')
Definition: checkNamespaceIntegrity.php:25
‪TYPO3\CMS\Core\Http\UploadedFile
Definition: UploadedFile.php:32
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNearestRecyclerFolder
‪Folder null getNearestRecyclerFolder(FileInterface $file)
Definition: ResourceStorage.php:2865
‪TYPO3\CMS\Core\Resource\ResourceStorage\countFoldersInFolder
‪int countFoldersInFolder(Folder $folder, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:2394
‪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:1279
‪TYPO3\CMS\Core\Resource\ResourceStorage\setConfiguration
‪setConfiguration(array $configuration)
Definition: ResourceStorage.php:277
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFileObject
‪File getFileObject($uid, array $fileData=[])
Definition: ResourceFactory.php:196
‪TYPO3\CMS\Core\Resource\ResourceStorage\updateProcessedFile
‪FileInterface updateProcessedFile($localFilePath, ProcessedFile $processedFile, Folder $processingFolder=null)
Definition: ResourceStorage.php:1258
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileRenamePermissions
‪assureFileRenamePermissions(FileInterface $file, $targetFileName)
Definition: ResourceStorage.php:1053
‪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:159
‪TYPO3\CMS\Core\Resource\ResourceStorage\$folders
‪foreach($this->getProcessingFolders() as $processingFolder) $folders
Definition: ResourceStorage.php:2380
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileWritePermissions
‪assureFileWritePermissions(FileInterface $file)
Definition: ResourceStorage.php:901
‪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:390
‪TYPO3\CMS\Core\Resource\Folder\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: Folder.php:180
‪TYPO3\CMS\Core\Http\fromRequest
‪@ fromRequest
Definition: ApplicationType.php:67
‪TYPO3\CMS\Core\Resource\ResourceStorage\$userPermissions
‪array $userPermissions
Definition: ResourceStorage.php:170
‪TYPO3\CMS\Core\Resource\Service\FileProcessingService
Definition: FileProcessingService.php:38
‪TYPO3\CMS\Core\Resource\Event\SanitizeFileNameEvent
Definition: SanitizeFileNameEvent.php:29
‪TYPO3\CMS\Core\Resource\AbstractFile\updateProperties
‪updateProperties(array $properties)
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:51
‪TYPO3\CMS\Core\Resource\ResourceStorage\unsetFileAndFolderNameFilters
‪unsetFileAndFolderNameFilters()
Definition: ResourceStorage.php:1463
‪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:696
‪TYPO3\CMS\Core\Resource\FileInterface\getMimeType
‪string getMimeType()
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException
Definition: FileOperationErrorException.php:22
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderIdentifiersInFolder
‪array getFolderIdentifiersInFolder($folderIdentifier, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1611
‪TYPO3\CMS\Core\Resource\Event\AfterFileReplacedEvent
Definition: AfterFileReplacedEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkUserActionPermission
‪bool checkUserActionPermission($action, $type)
Definition: ResourceStorage.php:669
‪TYPO3\CMS\Core\Resource\Event\AfterFolderDeletedEvent
Definition: AfterFolderDeletedEvent.php:27
‪TYPO3\CMS\Core\Resource\ResourceInterface\getParentFolder
‪FolderInterface getParentFolder()
‪TYPO3\CMS\Core\Http\UploadedFile\getTemporaryFileName
‪getTemporaryFileName()
Definition: UploadedFile.php:263
‪TYPO3\CMS\Core\Resource\Service\FileProcessingService\processFile
‪Resource ProcessedFile processFile(FileInterface $fileObject, ResourceStorage $targetStorage, $taskType, $configuration)
Definition: FileProcessingService.php:74
‪TYPO3\CMS\Core\Resource\Event\AfterFileDeletedEvent
Definition: AfterFileDeletedEvent.php:29
‪TYPO3\CMS\Core\Resource\Driver\StreamableDriverInterface
Definition: StreamableDriverInterface.php:29
‪TYPO3\CMS\Core\Resource\ResourceStorage\getPublicUrl
‪string null getPublicUrl(ResourceInterface $resourceObject)
Definition: ResourceStorage.php:1327
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUniqueName
‪string getUniqueName(FolderInterface $folder, $theFile, $dontCheckForUnique=false)
Definition: ResourceStorage.php:2589
‪TYPO3\CMS\Core\Resource\ResourceStorage\deleteFile
‪bool deleteFile($fileObject)
Definition: ResourceStorage.php:1823
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderDeletePermission
‪assureFolderDeletePermission(Folder $folder, $checkDeleteRecursively)
Definition: ResourceStorage.php:851
‪TYPO3\CMS\Core\Resource\Exception\InvalidHashException
Definition: InvalidHashException.php:27
‪TYPO3\CMS\Core\Resource\Event\BeforeFileContentsSetEvent
Definition: BeforeFileContentsSetEvent.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\getIndexer
‪Index Indexer getIndexer()
Definition: ResourceStorage.php:2823
‪TYPO3\CMS\Core\Resource\Folder\hasFolder
‪bool hasFolder($name)
Definition: Folder.php:418
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFolderInFolder
‪bool hasFolderInFolder($folderName, Folder $folder)
Definition: ResourceStorage.php:2419
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileIndexRepository
‪Index FileIndexRepository getFileIndexRepository()
Definition: ResourceStorage.php:2635
‪TYPO3\CMS\Core\Utility\PathUtility\pathinfo
‪static string string[] pathinfo(string $path, int $options=PATHINFO_ALL)
Definition: PathUtility.php:270
‪TYPO3\CMS\Core\Resource\ResourceStorage\copyFolder
‪Folder copyFolder(FolderInterface $folderToCopy, FolderInterface $targetParentFolder, $newFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2209
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static getUniqueId(string $prefix='')
Definition: StringUtility.php:29
‪TYPO3\CMS\Core\Resource\ProcessedFile\getName
‪string getName()
Definition: ProcessedFile.php:328
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_WRITABLE
‪const CAPABILITY_WRITABLE
Definition: ResourceStorageInterface.php:35
‪TYPO3\CMS\Core\Http\ApplicationType
‪ApplicationType
Definition: ApplicationType.php:56
‪TYPO3\CMS\Core\Resource\Event\AfterFileAddedEvent
Definition: AfterFileAddedEvent.php:30
‪TYPO3\CMS\Core\Resource\ResourceStorage\setDefault
‪setDefault($isDefault)
Definition: ResourceStorage.php:2831
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository\findOneByStorageAndIdentifier
‪array bool findOneByStorageAndIdentifier(ResourceStorage $storage, $identifier)
Definition: FileIndexRepository.php:122
‪TYPO3\CMS\Core\Resource\ResourceStorage\getName
‪string getName()
Definition: ResourceStorage.php:318
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileMounts
‪array $fileMounts
Definition: ResourceStorage.php:163
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileUploadPermissions
‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileSize)
Definition: ResourceStorage.php:1000
‪TYPO3\CMS\Core\Resource\AbstractFile\getStorage
‪ResourceStorage getStorage()
Definition: AbstractFile.php:395
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNestedProcessingFolder
‪Folder getNestedProcessingFolder(File $file, Folder $rootProcessingFolder)
Definition: ResourceStorage.php:2763
‪TYPO3\CMS\Core\Http\UploadedFile\getSize
‪int null getSize()
Definition: UploadedFile.php:218