‪TYPO3CMS  9.5
ResourceStorage.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use Psr\Http\Message\ResponseInterface;
40 
74 {
80  protected ‪$driver;
81 
87  protected ‪$storageRecord;
88 
94  protected ‪$configuration;
95 
99  protected ‪$fileProcessingService;
100 
109  protected ‪$evaluatePermissions = false;
110 
116  protected ‪$fileMounts = [];
117 
124  protected ‪$userPermissions = [];
125 
132  protected ‪$capabilities;
133 
137  protected ‪$signalSlotDispatcher;
138 
142  protected ‪$processingFolder;
143 
149  protected ‪$processingFolders;
150 
156  protected ‪$isOnline;
157 
161  protected ‪$isDefault = false;
162 
168  protected ‪$fileAndFolderNameFilters = [];
169 
173  const ‪PROCESSING_FOLDER_LEVELS = 2;
174 
181  public function ‪__construct(Driver\DriverInterface ‪$driver, array ‪$storageRecord)
182  {
183  $this->storageRecord = ‪$storageRecord;
184  $this->configuration = $this->‪getResourceFactoryInstance()->‪convertFlexFormDataToConfigurationArray($storageRecord['configuration'] ?? '');
185  $this->capabilities =
186  ($this->storageRecord['is_browsable'] ?? null ? ‪self::CAPABILITY_BROWSABLE : 0) |
187  ($this->storageRecord['is_public'] ?? null ? self::CAPABILITY_PUBLIC : 0) |
188  ($this->storageRecord['is_writable'] ?? null ? ‪self::CAPABILITY_WRITABLE : 0) |
189  // Always let the driver decide whether to set this capability
190  self::CAPABILITY_HIERARCHICAL_IDENTIFIERS;
191 
192  $this->driver = ‪$driver;
193  $this->driver->setStorageUid(‪$storageRecord['uid'] ?? null);
194  $this->driver->mergeConfigurationCapabilities($this->capabilities);
195  try {
196  $this->driver->processConfiguration();
197  } catch (‪Exception\InvalidConfigurationException $e) {
198  // Configuration error
199  $this->‪isOnline = false;
200 
201  $message = sprintf(
202  'Failed initializing storage [%d] "%s", error: %s',
203  $this->‪getUid(),
204  $this->‪getName(),
205  $e->getMessage()
206  );
207 
208  // create a dedicated logger instance because we need a logger in the constructor
209  GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class)->error($message);
210  }
211  $this->driver->initialize();
212  $this->capabilities = $this->driver->getCapabilities();
213 
214  $this->‪isDefault = (isset(‪$storageRecord['is_default']) && ‪$storageRecord['is_default'] == 1);
216  }
217 
223  public function ‪getConfiguration()
224  {
226  }
227 
233  public function ‪setConfiguration(array ‪$configuration)
234  {
235  $this->configuration = ‪$configuration;
236  }
237 
243  public function ‪getStorageRecord()
244  {
246  }
247 
254  public function ‪setDriver(Driver\DriverInterface ‪$driver)
255  {
256  $this->driver = ‪$driver;
257  return $this;
258  }
259 
265  protected function ‪getDriver()
266  {
267  return ‪$this->driver;
268  }
269 
275  public function ‪getName()
276  {
277  return $this->storageRecord['name'];
278  }
279 
285  public function ‪getUid()
286  {
287  return (int)($this->storageRecord['uid'] ?? 0);
288  }
289 
295  public function ‪hasChildren()
296  {
297  return true;
298  }
299 
300  /*********************************
301  * Capabilities
302  ********************************/
309  public function ‪getCapabilities()
310  {
311  return (int)‪$this->capabilities;
312  }
313 
320  protected function ‪hasCapability($capability)
321  {
322  return ($this->capabilities & $capability) == $capability;
323  }
324 
333  public function ‪isPublic()
334  {
335  return $this->‪hasCapability(self::CAPABILITY_PUBLIC);
336  }
337 
344  public function ‪isWritable()
345  {
346  return $this->‪hasCapability(self::CAPABILITY_WRITABLE);
347  }
348 
354  public function ‪isBrowsable()
355  {
356  return $this->‪isOnline() && $this->‪hasCapability(self::CAPABILITY_BROWSABLE);
357  }
358 
364  public function ‪hasHierarchicalIdentifiers(): bool
365  {
366  return $this->‪hasCapability(self::CAPABILITY_HIERARCHICAL_IDENTIFIERS);
367  }
368 
378  public function ‪searchFiles(‪FileSearchDemand $searchDemand, ‪Folder $folder = null, bool $useFilters = true): ‪FileSearchResultInterface
379  {
380  $folder = $folder ?? $this->‪getRootLevelFolder();
381  if (!$folder->checkActionPermission('read')) {
382  return new ‪EmptyFileSearchResult();
383  }
384 
387  $searchDemand->‪withFolder($folder)
388  ),
389  $this->driver,
390  $useFilters ? $this->getFileAndFolderNameFilters() : []
391  );
392  }
393 
399  public function ‪usesCaseSensitiveIdentifiers()
400  {
401  return $this->driver->isCaseSensitiveFileSystem();
402  }
403 
409  public function ‪isOnline()
410  {
411  if ($this->‪isOnline === null) {
412  if ($this->‪getUid() === 0) {
413  $this->‪isOnline = true;
414  }
415  // the storage is not marked as online for a longer time
416  if ($this->storageRecord['is_online'] == 0) {
417  $this->‪isOnline = false;
418  }
419  if ($this->‪isOnline !== false) {
420  // all files are ALWAYS available in the frontend
421  if (TYPO3_MODE === 'FE') {
422  $this->‪isOnline = true;
423  } else {
424  // check if the storage is disabled temporary for now
425  $registryObject = GeneralUtility::makeInstance(Registry::class);
426  $offlineUntil = $registryObject->get('core', 'sys_file_storage-' . $this->‪getUid() . '-offline-until');
427  if ($offlineUntil && $offlineUntil > time()) {
428  $this->‪isOnline = false;
429  } else {
430  $this->‪isOnline = true;
431  }
432  }
433  }
434  }
435  return ‪$this->isOnline;
436  }
437 
443  public function ‪autoExtractMetadataEnabled()
444  {
445  return !empty($this->storageRecord['auto_extract_metadata']);
446  }
447 
455  public function ‪markAsPermanentlyOffline()
456  {
457  if ($this->‪getUid() > 0) {
458  // @todo: move this to the storage repository
459  GeneralUtility::makeInstance(ConnectionPool::class)
460  ->getConnectionForTable('sys_file_storage')
461  ->update(
462  'sys_file_storage',
463  ['is_online' => 0],
464  ['uid' => (int)$this->‪getUid()]
465  );
466  }
467  $this->storageRecord['is_online'] = 0;
468  $this->‪isOnline = false;
469  }
470 
477  public function ‪markAsTemporaryOffline()
478  {
479  $registryObject = GeneralUtility::makeInstance(Registry::class);
480  $registryObject->set('core', 'sys_file_storage-' . $this->‪getUid() . '-offline-until', time() + 60 * 5);
481  $this->storageRecord['is_online'] = 0;
482  $this->‪isOnline = false;
483  }
484 
485  /*********************************
486  * User Permissions / File Mounts
487  ********************************/
497  public function ‪addFileMount($folderIdentifier, $additionalData = [])
498  {
499  // check for the folder before we add it as a filemount
500  if ($this->driver->folderExists($folderIdentifier) === false) {
501  // if there is an error, this is important and should be handled
502  // as otherwise the user would see the whole storage without any restrictions for the filemounts
503  throw new Exception\FolderDoesNotExistException('Folder for file mount ' . $folderIdentifier . ' does not exist.', 1334427099);
504  }
505  $data = $this->driver->getFolderInfoByIdentifier($folderIdentifier);
506  $folderObject = $this->‪getResourceFactoryInstance()->‪createFolderObject($this, $data['identifier'], $data['name']);
507  // Use the canonical identifier instead of the user provided one!
508  $folderIdentifier = $folderObject->‪getIdentifier();
509  if (
510  !empty($this->fileMounts[$folderIdentifier])
511  && empty($this->fileMounts[$folderIdentifier]['read_only'])
512  && !empty($additionalData['read_only'])
513  ) {
514  // Do not overwrite a regular mount with a read only mount
515  return;
516  }
517  if (empty($additionalData)) {
518  $additionalData = [
519  'path' => $folderIdentifier,
520  'title' => $folderIdentifier,
521  'folder' => $folderObject
522  ];
523  } else {
524  $additionalData['folder'] = $folderObject;
525  if (!isset($additionalData['title'])) {
526  $additionalData['title'] = $folderIdentifier;
527  }
528  }
529  $this->fileMounts[$folderIdentifier] = $additionalData;
530  }
531 
537  public function ‪getFileMounts()
538  {
539  return ‪$this->fileMounts;
540  }
541 
550  public function ‪isWithinFileMountBoundaries($subject, $checkWriteAccess = false)
551  {
552  if (!$this->evaluatePermissions) {
553  return true;
554  }
555  $isWithinFileMount = false;
556  if (!$subject) {
557  $subject = $this->‪getRootLevelFolder();
558  }
559  $identifier = $subject->getIdentifier();
560 
561  // Allow access to processing folder
562  if ($this->‪isWithinProcessingFolder($identifier)) {
563  $isWithinFileMount = true;
564  } else {
565  // Check if the identifier of the subject is within at
566  // least one of the file mounts
567  $writableFileMountAvailable = false;
568  foreach ($this->fileMounts as $fileMount) {
570  $folder = $fileMount['folder'];
571  if ($this->driver->isWithin($folder->getIdentifier(), $identifier)) {
572  $isWithinFileMount = true;
573  if (!$checkWriteAccess) {
574  break;
575  }
576  if (empty($fileMount['read_only'])) {
577  $writableFileMountAvailable = true;
578  break;
579  }
580  }
581  }
582  $isWithinFileMount = $checkWriteAccess ? $writableFileMountAvailable : $isWithinFileMount;
583  }
584  return $isWithinFileMount;
585  }
586 
594  {
595  $this->evaluatePermissions = (bool)‪$evaluatePermissions;
596  }
597 
604  public function ‪getEvaluatePermissions()
605  {
607  }
608 
614  public function ‪setUserPermissions(array ‪$userPermissions)
615  {
616  $this->userPermissions = ‪$userPermissions;
617  }
618 
627  public function ‪checkUserActionPermission($action, $type)
628  {
629  if (!$this->evaluatePermissions) {
630  return true;
631  }
632 
633  $allow = false;
634  if (!empty($this->userPermissions[strtolower($action) . ucfirst(strtolower($type))])) {
635  $allow = true;
636  }
637 
638  return $allow;
639  }
640 
654  public function ‪checkFileActionPermission($action, ‪FileInterface $file)
655  {
656  $isProcessedFile = $file instanceof ‪ProcessedFile;
657  // Check 1: Allow editing meta data of a file if it is in mount boundaries of a writable file mount
658  if ($action === 'editMeta') {
659  return !$isProcessedFile && $this->‪isWithinFileMountBoundaries($file, true);
660  }
661  // Check 2: Does the user have permission to perform the action? e.g. "readFile"
662  if (!$isProcessedFile && $this->‪checkUserActionPermission($action, 'File') === false) {
663  return false;
664  }
665  // Check 3: No action allowed on files for denied file extensions
666  if (!$this->‪checkFileExtensionPermission($file->‪getName())) {
667  return false;
668  }
669  $isReadCheck = false;
670  if (in_array($action, ['read', 'copy', 'move', 'replace'], true)) {
671  $isReadCheck = true;
672  }
673  $isWriteCheck = false;
674  if (in_array($action, ['add', 'write', 'move', 'rename', 'replace', 'delete'], true)) {
675  $isWriteCheck = true;
676  }
677  // Check 4: Does the user have the right to perform the action?
678  // (= is he within the file mount borders)
679  if (!$isProcessedFile && !$this->‪isWithinFileMountBoundaries($file, $isWriteCheck)) {
680  return false;
681  }
682 
683  $isMissing = false;
684  if (!$isProcessedFile && $file instanceof ‪File) {
685  $isMissing = $file->isMissing();
686  }
687 
688  if ($this->driver->fileExists($file->‪getIdentifier()) === false) {
689  $file->setMissing(true);
690  $isMissing = true;
691  }
692 
693  // Check 5: Check the capabilities of the storage (and the driver)
694  if ($isWriteCheck && ($isMissing || !$this->‪isWritable())) {
695  return false;
696  }
697 
698  // Check 6: "File permissions" of the driver (only when file isn't marked as missing)
699  if (!$isMissing) {
700  $filePermissions = $this->driver->getPermissions($file->‪getIdentifier());
701  if ($isReadCheck && !$filePermissions['r']) {
702  return false;
703  }
704  if ($isWriteCheck && !$filePermissions['w']) {
705  return false;
706  }
707  }
708  return true;
709  }
710 
721  public function ‪checkFolderActionPermission($action, Folder $folder = null)
722  {
723  // Check 1: Does the user have permission to perform the action? e.g. "writeFolder"
724  if ($this->‪checkUserActionPermission($action, 'Folder') === false) {
725  return false;
726  }
727 
728  // If we do not have a folder here, we cannot do further checks
729  if ($folder === null) {
730  return true;
731  }
732 
733  $isReadCheck = false;
734  if (in_array($action, ['read', 'copy'], true)) {
735  $isReadCheck = true;
736  }
737  $isWriteCheck = false;
738  if (in_array($action, ['add', 'move', 'write', 'delete', 'rename'], true)) {
739  $isWriteCheck = true;
740  }
741  // Check 2: Does the user has the right to perform the action?
742  // (= is he within the file mount borders)
743  if (!$this->‪isWithinFileMountBoundaries($folder, $isWriteCheck)) {
744  return false;
745  }
746  // Check 3: Check the capabilities of the storage (and the driver)
747  if ($isReadCheck && !$this->‪isBrowsable()) {
748  return false;
749  }
750  if ($isWriteCheck && !$this->‪isWritable()) {
751  return false;
752  }
753 
754  // Check 4: "Folder permissions" of the driver
755  $folderPermissions = $this->driver->getPermissions($folder->getIdentifier());
756  if ($isReadCheck && !$folderPermissions['r']) {
757  return false;
758  }
759  if ($isWriteCheck && !$folderPermissions['w']) {
760  return false;
761  }
762  return true;
763  }
764 
770  public function ‪checkFileAndFolderNameFilters(ResourceInterface $fileOrFolder)
771  {
772  trigger_error(__METHOD__ . ' is deprecated. This method will be removed without substitution, use the ResourceStorage API instead', \E_USER_DEPRECATED);
773  foreach ($this->fileAndFolderNameFilters as $filter) {
774  if (is_callable($filter)) {
775  $result = call_user_func($filter, $fileOrFolder->getName(), $fileOrFolder->getIdentifier(), $fileOrFolder->getParentFolder()->getIdentifier(), [], $this->driver);
776  // We have to use -1 as the „don't include“ return value, as call_user_func() will return FALSE
777  // If calling the method succeeded and thus we can't use that as a return value.
778  if ($result === -1) {
779  return false;
780  }
781  if ($result === false) {
782  throw new \RuntimeException(
783  'Could not apply file/folder name filter ' . $filter[0] . '::' . $filter[1],
784  1525342106
785  );
786  }
787  }
788  }
789 
790  return true;
791  }
792 
800  protected function ‪checkFileExtensionPermission($fileName)
801  {
802  $fileName = $this->driver->sanitizeFileName($fileName);
803  return GeneralUtility::verifyFilenameAgainstDenyPattern($fileName);
804  }
805 
812  protected function ‪assureFolderReadPermission(Folder $folder = null)
813  {
814  if (!$this->‪checkFolderActionPermission('read', $folder)) {
815  if ($folder === null) {
816  throw new Exception\InsufficientFolderAccessPermissionsException(
817  'You are not allowed to read folders',
818  1430657869
819  );
820  }
821  throw new Exception\InsufficientFolderAccessPermissionsException(
822  'You are not allowed to access the given folder: "' . $folder->getName() . '"',
823  1375955684
824  );
825  }
826  }
827 
837  protected function ‪assureFolderDeletePermission(Folder $folder, $checkDeleteRecursively)
838  {
839  // Check user permissions for recursive deletion if it is requested
840  if ($checkDeleteRecursively && !$this->‪checkUserActionPermission('recursivedelete', 'Folder')) {
841  throw new Exception\InsufficientUserPermissionsException('You are not allowed to delete folders recursively', 1377779423);
842  }
843  // Check user action permission
844  if (!$this->‪checkFolderActionPermission('delete', $folder)) {
845  throw new Exception\InsufficientFolderAccessPermissionsException(
846  'You are not allowed to delete the given folder: "' . $folder->getName() . '"',
847  1377779039
848  );
849  }
850  // Check if the user has write permissions to folders
851  // Would be good if we could check for actual write permissions in the containig folder
852  // but we cannot since we have no access to the containing folder of this file.
853  if (!$this->‪checkUserActionPermission('write', 'Folder')) {
854  throw new Exception\InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377779111);
855  }
856  }
857 
865  protected function ‪assureFileReadPermission(FileInterface $file)
866  {
867  if (!$this->‪checkFileActionPermission('read', $file)) {
868  throw new Exception\InsufficientFileAccessPermissionsException(
869  'You are not allowed to access that file: "' . $file->getName() . '"',
870  1375955429
871  );
872  }
873  if (!$this->‪checkFileExtensionPermission($file->getName())) {
874  throw new Exception\IllegalFileExtensionException(
875  'You are not allowed to use that file extension. File: "' . $file->getName() . '"',
876  1375955430
877  );
878  }
879  }
880 
889  protected function ‪assureFileWritePermissions(FileInterface $file)
890  {
891  // Check if user is allowed to write the file and $file is writable
892  if (!$this->‪checkFileActionPermission('write', $file)) {
893  throw new Exception\InsufficientFileWritePermissionsException('Writing to file "' . $file->getIdentifier() . '" is not allowed.', 1330121088);
894  }
895  if (!$this->‪checkFileExtensionPermission($file->getName())) {
896  throw new Exception\IllegalFileExtensionException('You are not allowed to edit a file with extension "' . $file->getExtension() . '"', 1366711933);
897  }
898  }
899 
907  protected function ‪assureFileReplacePermissions(FileInterface $file)
908  {
909  // Check if user is allowed to replace the file and $file is writable
910  if (!$this->‪checkFileActionPermission('replace', $file)) {
911  throw new Exception\InsufficientFileWritePermissionsException('Replacing file "' . $file->getIdentifier() . '" is not allowed.', 1436899571);
912  }
913  // Check if parentFolder is writable for the user
914  if (!$this->‪checkFolderActionPermission('write', $file->getParentFolder())) {
915  throw new Exception\InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $file->getIdentifier() . '"', 1436899572);
916  }
917  }
918 
927  protected function ‪assureFileDeletePermissions(FileInterface $file)
928  {
929  // Check for disallowed file extensions
930  if (!$this->‪checkFileExtensionPermission($file->getName())) {
931  throw new Exception\IllegalFileExtensionException('You are not allowed to delete a file with extension "' . $file->getExtension() . '"', 1377778916);
932  }
933  // Check further permissions if file is not a processed file
934  if (!$file instanceof ProcessedFile) {
935  // Check if user is allowed to delete the file and $file is writable
936  if (!$this->‪checkFileActionPermission('delete', $file)) {
937  throw new Exception\InsufficientFileWritePermissionsException('You are not allowed to delete the file "' . $file->getIdentifier() . '"', 1319550425);
938  }
939  // Check if the user has write permissions to folders
940  // Would be good if we could check for actual write permissions in the containig folder
941  // but we cannot since we have no access to the containing folder of this file.
942  if (!$this->‪checkUserActionPermission('write', 'Folder')) {
943  throw new Exception\InsufficientFolderWritePermissionsException('Writing to folders is not allowed.', 1377778702);
944  }
945  }
946  }
947 
959  protected function ‪assureFileAddPermissions($targetFolder, $targetFileName)
960  {
961  // Check for a valid file extension
962  if (!$this->‪checkFileExtensionPermission($targetFileName)) {
963  throw new Exception\IllegalFileExtensionException('Extension of file name is not allowed in "' . $targetFileName . '"!', 1322120271);
964  }
965  // Makes sure the user is allowed to upload
966  if (!$this->‪checkUserActionPermission('add', 'File')) {
967  throw new Exception\InsufficientUserPermissionsException('You are not allowed to add files to this storage "' . $this->‪getUid() . '"', 1376992145);
968  }
969  // Check if targetFolder is writable
970  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
971  throw new Exception\InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetFolder->getIdentifier() . '"', 1322120356);
972  }
973  }
974 
990  protected function ‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileSize)
991  {
992  // Makes sure this is an uploaded file
993  if (!is_uploaded_file($localFilePath)) {
994  throw new Exception\UploadException('The upload has failed, no uploaded file found!', 1322110455);
995  }
996  // Max upload size (kb) for files.
997  $maxUploadFileSize = GeneralUtility::getMaxUploadFileSize() * 1024;
998  if ($maxUploadFileSize > 0 && $uploadedFileSize >= $maxUploadFileSize) {
999  unlink($localFilePath);
1000  throw new Exception\UploadSizeException('The uploaded file exceeds the size-limit of ' . $maxUploadFileSize . ' bytes', 1322110041);
1001  }
1002  $this->‪assureFileAddPermissions($targetFolder, $targetFileName);
1003  }
1004 
1016  protected function ‪assureFileMovePermissions(‪FileInterface $file, ‪Folder $targetFolder, $targetFileName)
1017  {
1018  // Check if targetFolder is within this storage
1019  if ($this->‪getUid() !== $targetFolder->‪getStorage()->‪getUid()) {
1020  throw new \RuntimeException('The target folder is not in the same storage. Target folder given: "' . $targetFolder->‪getIdentifier() . '"', 1422553107);
1021  }
1022  // Check for a valid file extension
1023  if (!$this->‪checkFileExtensionPermission($targetFileName)) {
1024  throw new Exception\IllegalFileExtensionException('Extension of file name is not allowed in "' . $targetFileName . '"!', 1378243279);
1025  }
1026  // Check if user is allowed to move and $file is readable and writable
1027  if (!$file->‪getStorage()->‪checkFileActionPermission('move', $file)) {
1028  throw new Exception\InsufficientUserPermissionsException('You are not allowed to move files to storage "' . $this->‪getUid() . '"', 1319219349);
1029  }
1030  // Check if target folder is writable
1031  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1032  throw new Exception\InsufficientFolderAccessPermissionsException('You are not allowed to write to the target folder "' . $targetFolder->‪getIdentifier() . '"', 1319219350);
1033  }
1034  }
1035 
1046  protected function ‪assureFileRenamePermissions(FileInterface $file, $targetFileName)
1047  {
1048  // Check if file extension is allowed
1049  if (!$this->‪checkFileExtensionPermission($targetFileName) || !$this->‪checkFileExtensionPermission($file->getName())) {
1050  throw new Exception\IllegalFileExtensionException('You are not allowed to rename a file with this extension. File given: "' . $file->getName() . '"', 1371466663);
1051  }
1052  // Check if user is allowed to rename
1053  if (!$this->‪checkFileActionPermission('rename', $file)) {
1054  throw new Exception\InsufficientUserPermissionsException('You are not allowed to rename files. File given: "' . $file->getName() . '"', 1319219351);
1055  }
1056  // Check if the user is allowed to write to folders
1057  // Although it would be good to check, we cannot check here if the folder actually is writable
1058  // because we do not know in which folder the file resides.
1059  // So we rely on the driver to throw an exception in case the renaming failed.
1060  if (!$this->‪checkFolderActionPermission('write')) {
1061  throw new Exception\InsufficientFileWritePermissionsException('You are not allowed to write to folders', 1319219352);
1062  }
1063  }
1064 
1079  protected function ‪assureFileCopyPermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
1080  {
1081  // Check if targetFolder is within this storage, this should never happen
1082  if ($this->‪getUid() != $targetFolder->getStorage()->getUid()) {
1083  throw new Exception('The operation of the folder cannot be called by this storage "' . $this->‪getUid() . '"', 1319550405);
1084  }
1085  // Check if user is allowed to copy
1086  if (!$file->getStorage()->checkFileActionPermission('copy', $file)) {
1087  throw new Exception\InsufficientFileReadPermissionsException('You are not allowed to copy the file "' . $file->getIdentifier() . '"', 1319550426);
1088  }
1089  // Check if targetFolder is writable
1090  if (!$this->‪checkFolderActionPermission('write', $targetFolder)) {
1091  throw new Exception\InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetFolder->getIdentifier() . '"', 1319550435);
1092  }
1093  // Check for a valid file extension
1094  if (!$this->‪checkFileExtensionPermission($targetFileName) || !$this->‪checkFileExtensionPermission($file->getName())) {
1095  throw new Exception\IllegalFileExtensionException('You are not allowed to copy a file of that type.', 1319553317);
1096  }
1097  }
1098 
1113  protected function ‪assureFolderCopyPermissions(FolderInterface $folderToCopy, FolderInterface $targetParentFolder)
1114  {
1115  // Check if targetFolder is within this storage, this should never happen
1116  if ($this->‪getUid() !== $targetParentFolder->getStorage()->getUid()) {
1117  throw new Exception('The operation of the folder cannot be called by this storage "' . $this->‪getUid() . '"', 1377777624);
1118  }
1119  if (!$folderToCopy instanceof Folder) {
1120  throw new \RuntimeException('The folder "' . $folderToCopy->getIdentifier() . '" to copy is not of type folder.', 1384209020);
1121  }
1122  // Check if user is allowed to copy and the folder is readable
1123  if (!$folderToCopy->getStorage()->checkFolderActionPermission('copy', $folderToCopy)) {
1124  throw new Exception\InsufficientFileReadPermissionsException('You are not allowed to copy the folder "' . $folderToCopy->getIdentifier() . '"', 1377777629);
1125  }
1126  if (!$targetParentFolder instanceof Folder) {
1127  throw new \RuntimeException('The target folder "' . $targetParentFolder->getIdentifier() . '" is not of type folder.', 1384209021);
1128  }
1129  // Check if targetFolder is writable
1130  if (!$this->‪checkFolderActionPermission('write', $targetParentFolder)) {
1131  throw new Exception\InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetParentFolder->getIdentifier() . '"', 1377777635);
1132  }
1133  }
1134 
1149  protected function ‪assureFolderMovePermissions(FolderInterface $folderToMove, FolderInterface $targetParentFolder)
1150  {
1151  // Check if targetFolder is within this storage, this should never happen
1152  if ($this->‪getUid() !== $targetParentFolder->getStorage()->getUid()) {
1153  throw new \InvalidArgumentException('Cannot move a folder into a folder that does not belong to this storage.', 1325777289);
1154  }
1155  if (!$folderToMove instanceof Folder) {
1156  throw new \RuntimeException('The folder "' . $folderToMove->getIdentifier() . '" to move is not of type Folder.', 1384209022);
1157  }
1158  // Check if user is allowed to move and the folder is writable
1159  // In fact we would need to check if the parent folder of the folder to move is writable also
1160  // But as of now we cannot extract the parent folder from this folder
1161  if (!$folderToMove->getStorage()->checkFolderActionPermission('move', $folderToMove)) {
1162  throw new Exception\InsufficientFileReadPermissionsException('You are not allowed to copy the folder "' . $folderToMove->getIdentifier() . '"', 1377778045);
1163  }
1164  if (!$targetParentFolder instanceof Folder) {
1165  throw new \RuntimeException('The target folder "' . $targetParentFolder->getIdentifier() . '" is not of type Folder.', 1384209023);
1166  }
1167  // Check if targetFolder is writable
1168  if (!$this->‪checkFolderActionPermission('write', $targetParentFolder)) {
1169  throw new Exception\InsufficientFolderWritePermissionsException('You are not allowed to write to the target folder "' . $targetParentFolder->getIdentifier() . '"', 1377778049);
1170  }
1171  }
1172 
1183  public function ‪sanitizeFileName($fileName, Folder $targetFolder = null)
1184  {
1185  $targetFolder = $targetFolder ?: $this->‪getDefaultFolder();
1186  $fileName = $this->driver->sanitizeFileName($fileName);
1187 
1188  // The file name could be changed by an external slot
1189  $fileName = $this->‪emitSanitizeFileNameSignal($fileName, $targetFolder);
1190 
1191  return $fileName;
1192  }
1193 
1194  /********************
1195  * FILE ACTIONS
1196  ********************/
1210  public function ‪addFile($localFilePath, ‪Folder $targetFolder, $targetFileName = '', $conflictMode = ‪DuplicationBehavior::RENAME, $removeOriginal = true)
1211  {
1212  $localFilePath = ‪PathUtility::getCanonicalPath($localFilePath);
1213  // File is not available locally NOR is it an uploaded file
1214  if (!is_uploaded_file($localFilePath) && !file_exists($localFilePath)) {
1215  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552745);
1216  }
1217  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
1218  $targetFolder = $targetFolder ?: $this->‪getDefaultFolder();
1219  $targetFileName = $this->‪sanitizeFileName($targetFileName ?: ‪PathUtility::basename($localFilePath), $targetFolder);
1220 
1221  $targetFileName = $this->‪emitPreFileAddSignal($targetFileName, $targetFolder, $localFilePath);
1222 
1223  $this->‪assureFileAddPermissions($targetFolder, $targetFileName);
1224 
1225  $replaceExisting = false;
1226  if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && $this->driver->fileExistsInFolder($targetFileName, $targetFolder->‪getIdentifier())) {
1227  throw new Exception\ExistingTargetFileNameException('File "' . $targetFileName . '" already exists in folder ' . $targetFolder->‪getIdentifier(), 1322121068);
1228  }
1229  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
1230  $targetFileName = $this->‪getUniqueName($targetFolder, $targetFileName);
1231  } elseif ($conflictMode->equals(‪DuplicationBehavior::REPLACE) && $this->driver->fileExistsInFolder($targetFileName, $targetFolder->‪getIdentifier())) {
1232  $replaceExisting = true;
1233  }
1234 
1235  $fileIdentifier = $this->driver->addFile($localFilePath, $targetFolder->‪getIdentifier(), $targetFileName, $removeOriginal);
1236  $file = $this->‪getResourceFactoryInstance()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $fileIdentifier);
1237 
1238  if ($replaceExisting && $file instanceof ‪File) {
1239  $this->‪getIndexer()->updateIndexEntry($file);
1240  }
1241  if ($this->‪autoExtractMetadataEnabled()) {
1242  $this->‪getIndexer()->extractMetaData($file);
1243  }
1244 
1245  $this->‪emitPostFileAddSignal($file, $targetFolder);
1247  return $file;
1248  }
1249 
1260  public function ‪updateProcessedFile($localFilePath, ‪ProcessedFile $processedFile, ‪Folder ‪$processingFolder = null)
1261  {
1262  if (!file_exists($localFilePath)) {
1263  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552746);
1264  }
1265  if (‪$processingFolder === null) {
1267  }
1268  $fileIdentifier = $this->driver->addFile($localFilePath, ‪$processingFolder->‪getIdentifier(), $processedFile->‪getName());
1269  // @todo check if we have to update the processed file other then the identifier
1270  $processedFile->‪setIdentifier($fileIdentifier);
1271  return $processedFile;
1272  }
1273 
1282  public function ‪hashFile(‪FileInterface $fileObject, $hash)
1283  {
1284  return $this->‪hashFileByIdentifier($fileObject->‪getIdentifier(), $hash);
1285  }
1286 
1295  public function ‪hashFileByIdentifier($fileIdentifier, $hash)
1296  {
1297  $hash = $this->driver->hash($fileIdentifier, $hash);
1298  if (!is_string($hash) || $hash === '') {
1299  throw new ‪InvalidHashException('Hash has to be non-empty string.', 1551950301);
1300  }
1301  return $hash;
1302  }
1303 
1312  public function ‪hashFileIdentifier($file)
1313  {
1314  if (is_object($file) && $file instanceof FileInterface) {
1316  $file = $file->getIdentifier();
1317  }
1318  return $this->driver->hashIdentifier($file);
1319  }
1320 
1331  public function ‪getPublicUrl(ResourceInterface $resourceObject, $relativeToCurrentScript = false)
1332  {
1333  $publicUrl = null;
1334  if ($this->‪isOnline()) {
1335  // Pre-process the public URL by an accordant slot
1336  $this->‪emitPreGeneratePublicUrlSignal($resourceObject, $relativeToCurrentScript, ['publicUrl' => &$publicUrl]);
1337 
1338  if (
1339  $publicUrl === null
1340  && $resourceObject instanceof File
1341  && ($helper = ‪OnlineMediaHelperRegistry::getInstance()->getOnlineMediaHelper($resourceObject)) !== false
1342  ) {
1343  $publicUrl = $helper->getPublicUrl($resourceObject, $relativeToCurrentScript);
1344  }
1345 
1346  // If slot did not handle the signal, use the default way to determine public URL
1347  if ($publicUrl === null) {
1348  if ($this->‪hasCapability(self::CAPABILITY_PUBLIC)) {
1349  $publicUrl = $this->driver->getPublicUrl($resourceObject->getIdentifier());
1350  }
1351 
1352  if ($publicUrl === null && $resourceObject instanceof FileInterface) {
1353  $queryParameterArray = ['eID' => 'dumpFile', 't' => ''];
1354  if ($resourceObject instanceof File) {
1355  $queryParameterArray['f'] = $resourceObject->getUid();
1356  $queryParameterArray['t'] = 'f';
1357  } elseif ($resourceObject instanceof ProcessedFile) {
1358  $queryParameterArray['p'] = $resourceObject->getUid();
1359  $queryParameterArray['t'] = 'p';
1360  }
1361 
1362  $queryParameterArray['token'] = GeneralUtility::hmac(implode('|', $queryParameterArray), 'resourceStorageDumpFile');
1363  $publicUrl = GeneralUtility::locationHeaderUrl(‪PathUtility::getAbsoluteWebPath(‪Environment::getPublicPath() . '/index.php'));
1364  $publicUrl .= '?' . http_build_query($queryParameterArray, '', '&', PHP_QUERY_RFC3986);
1365  }
1366 
1367  // If requested, make the path relative to the current script in order to make it possible
1368  // to use the relative file
1369  if ($publicUrl !== null && $relativeToCurrentScript && !GeneralUtility::isValidUrl($publicUrl)) {
1370  $absolutePathToContainingFolder = ‪PathUtility::dirname(‪Environment::getPublicPath() . '/' . $publicUrl);
1371  $pathPart = ‪PathUtility::getRelativePathTo($absolutePathToContainingFolder);
1372  $filePart = substr(‪Environment::getPublicPath() . '/' . $publicUrl, strlen($absolutePathToContainingFolder) + 1);
1373  $publicUrl = $pathPart . $filePart;
1374  }
1375  }
1376  }
1377  return $publicUrl;
1378  }
1379 
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 
1407  public function ‪getFileForLocalProcessing(FileInterface $fileObject, $writable = true)
1408  {
1409  $filePath = $this->driver->getFileForLocalProcessing($fileObject->getIdentifier(), $writable);
1410  return $filePath;
1411  }
1412 
1419  public function ‪getFile($identifier)
1420  {
1421  $file = $this->‪getFileFactory()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $identifier);
1422  if (!$this->driver->fileExists($identifier)) {
1423  $file->‪setMissing(true);
1424  }
1425  return $file;
1426  }
1427 
1435  public function ‪getFileInfo(FileInterface $fileObject)
1436  {
1437  return $this->‪getFileInfoByIdentifier($fileObject->getIdentifier());
1438  }
1439 
1448  public function ‪getFileInfoByIdentifier($identifier, array $propertiesToExtract = [])
1449  {
1450  return $this->driver->getFileInfoByIdentifier($identifier, $propertiesToExtract);
1451  }
1452 
1456  public function ‪unsetFileAndFolderNameFilters()
1457  {
1458  $this->fileAndFolderNameFilters = [];
1459  }
1465  {
1466  $this->fileAndFolderNameFilters = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['defaultFilterCallbacks'];
1467  }
1468 
1474  public function ‪getFileAndFolderNameFilters()
1475  {
1477  }
1483  public function ‪setFileAndFolderNameFilters(array $filters)
1484  {
1485  $this->fileAndFolderNameFilters = $filters;
1486  return $this;
1487  }
1492  public function ‪addFileAndFolderNameFilter($filter)
1493  {
1494  $this->fileAndFolderNameFilters[] = $filter;
1495  }
1496 
1502  public function ‪getFolderIdentifierFromFileIdentifier($fileIdentifier)
1503  {
1504  return $this->driver->getParentFolderIdentifierOfIdentifier($fileIdentifier);
1505  }
1506 
1514  public function ‪getFileInFolder($fileName, Folder $folder)
1515  {
1516  $identifier = $this->driver->getFileInFolder($fileName, $folder->getIdentifier());
1517  return $this->‪getFileFactory()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $identifier);
1518  }
1519 
1535  public function ‪getFilesInFolder(Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
1536  {
1537  $this->‪assureFolderReadPermission($folder);
1538 
1539  $rows = $this->‪getFileIndexRepository()->‪findByFolder($folder);
1540 
1541  $filters = $useFilters == true ? $this->fileAndFolderNameFilters : [];
1542  $fileIdentifiers = array_values($this->driver->getFilesInFolder($folder->getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev));
1543 
1544  $items = [];
1545  foreach ($fileIdentifiers as $identifier) {
1546  if (isset($rows[$identifier])) {
1547  $fileObject = $this->‪getFileFactory()->‪getFileObject($rows[$identifier]['uid'], $rows[$identifier]);
1548  } else {
1549  $fileObject = $this->‪getFileFactory()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $identifier);
1550  }
1551  if ($fileObject instanceof FileInterface) {
1552  $key = $fileObject->‪getName();
1553  while (isset($items[$key])) {
1554  $key .= 'z';
1555  }
1556  $items[$key] = $fileObject;
1557  }
1558  }
1559 
1560  return $items;
1561  }
1562 
1569  public function ‪getFileIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
1570  {
1571  $filters = $useFilters == true ? $this->fileAndFolderNameFilters : [];
1572  return $this->driver->getFilesInFolder($folderIdentifier, 0, 0, $recursive, $filters);
1573  }
1574 
1582  public function ‪countFilesInFolder(Folder $folder, $useFilters = true, $recursive = false)
1583  {
1584  $this->‪assureFolderReadPermission($folder);
1585  $filters = $useFilters ? $this->fileAndFolderNameFilters : [];
1586  return $this->driver->countFilesInFolder($folder->getIdentifier(), $recursive, $filters);
1587  }
1588 
1595  public function ‪getFolderIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
1596  {
1597  $filters = $useFilters == true ? $this->fileAndFolderNameFilters : [];
1598  return $this->driver->getFoldersInFolder($folderIdentifier, 0, 0, $recursive, $filters);
1599  }
1600 
1607  public function ‪hasFile($identifier)
1608  {
1609  // Allow if identifier is in processing folder
1610  if (!$this->‪isWithinProcessingFolder($identifier)) {
1612  }
1613  return $this->driver->fileExists($identifier);
1614  }
1615 
1621  public function ‪getProcessingFolders()
1622  {
1623  if ($this->processingFolders === null) {
1624  $this->processingFolders = [];
1625  $this->processingFolders[] = $this->‪getProcessingFolder();
1627  $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
1628  $allStorages = $storageRepository->findAll();
1629  foreach ($allStorages as $storage) {
1630  // To circumvent the permission check of the folder, we use the factory to create it "manually" instead of directly using $storage->getProcessingFolder()
1631  // See #66695 for details
1632  list($storageUid, $processingFolderIdentifier) = array_pad(GeneralUtility::trimExplode(':', $storage->getStorageRecord()['processingfolder']), 2, null);
1633  if (empty($processingFolderIdentifier) || (int)$storageUid !== $this->‪getUid()) {
1634  continue;
1635  }
1636  $potentialProcessingFolder = $this->‪getResourceFactoryInstance()->‪createFolderObject($this, $processingFolderIdentifier, $processingFolderIdentifier);
1637  if ($potentialProcessingFolder->getStorage() === $this && $potentialProcessingFolder->getIdentifier() !== $this->getProcessingFolder()->getIdentifier()) {
1638  $this->processingFolders[] = $potentialProcessingFolder;
1639  }
1640  }
1641  }
1642 
1644  }
1645 
1653  public function ‪isProcessingFolder(Folder $folder)
1654  {
1655  $isProcessingFolder = false;
1656  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
1657  if ($folder->getCombinedIdentifier() === ‪$processingFolder->‪getCombinedIdentifier()) {
1658  $isProcessingFolder = true;
1659  break;
1660  }
1661  }
1662  return $isProcessingFolder;
1663  }
1664 
1672  public function ‪hasFileInFolder($fileName, ‪Folder $folder)
1673  {
1674  $this->‪assureFolderReadPermission($folder);
1675  return $this->driver->fileExistsInFolder($fileName, $folder->‪getIdentifier());
1676  }
1677 
1686  public function ‪getFileContents($file)
1687  {
1689  return $this->driver->getFileContents($file->getIdentifier());
1690  }
1691 
1702  public function ‪dumpFileContents(‪FileInterface $file, $asDownload = false, $alternativeFilename = null, $overrideMimeType = null)
1703  {
1704  trigger_error('ResourceStorage->dumpFileContents() will be removed in TYPO3 v10.0. Use streamFile() instead.', E_USER_DEPRECATED);
1705 
1706  $downloadName = $alternativeFilename ?: $file->‪getName();
1707  $contentDisposition = $asDownload ? 'attachment' : 'inline';
1708  header('Content-Disposition: ' . $contentDisposition . '; filename="' . $downloadName . '"');
1709  header('Content-Type: ' . ($overrideMimeType ?: $file->‪getMimeType()));
1710  header('Content-Length: ' . $file->‪getSize());
1711 
1712  // Cache-Control header is needed here to solve an issue with browser IE8 and lower
1713  // See for more information: http://support.microsoft.com/kb/323308
1714  header("Cache-Control: ''");
1715  header(
1716  'Last-Modified: ' .
1717  gmdate('D, d M Y H:i:s', array_pop($this->driver->getFileInfoByIdentifier($file->‪getIdentifier(), ['mtime']))) . ' GMT',
1718  true,
1719  200
1720  );
1721  ob_clean();
1722  flush();
1723  while (ob_get_level() > 0) {
1724  ob_end_clean();
1725  }
1726  $this->driver->dumpFileContents($file->‪getIdentifier());
1727  }
1728 
1738  public function ‪streamFile(
1739  FileInterface $file,
1740  bool $asDownload = false,
1741  string $alternativeFilename = null,
1742  string $overrideMimeType = null
1743  ): ResponseInterface {
1744  if (!$this->driver instanceof StreamableDriverInterface) {
1745  return $this->‪getPseudoStream($file, $asDownload, $alternativeFilename, $overrideMimeType);
1746  }
1747 
1748  $properties = [
1749  'as_download' => $asDownload,
1750  'filename_overwrite' => $alternativeFilename,
1751  'mimetype_overwrite' => $overrideMimeType,
1752  ];
1753  return $this->driver->streamFile($file->getIdentifier(), $properties);
1754  }
1755 
1765  protected function ‪getPseudoStream(
1766  ‪FileInterface $file,
1767  bool $asDownload = false,
1768  string $alternativeFilename = null,
1769  string $overrideMimeType = null
1770  ) {
1771  $downloadName = $alternativeFilename ?: $file->‪getName();
1772  $contentDisposition = $asDownload ? 'attachment' : 'inline';
1773 
1774  $stream = new ‪FalDumpFileContentsDecoratorStream($file->‪getIdentifier(), $this->driver, $file->‪getSize());
1775  $headers = [
1776  'Content-Disposition' => $contentDisposition . '; filename="' . $downloadName . '"',
1777  'Content-Type' => $overrideMimeType ?: $file->‪getMimeType(),
1778  'Content-Length' => (string)$file->‪getSize(),
1779  'Last-Modified' => gmdate('D, d M Y H:i:s', array_pop($this->driver->getFileInfoByIdentifier($file->‪getIdentifier(), ['mtime']))) . ' GMT',
1780  // Cache-Control header is needed here to solve an issue with browser IE8 and lower
1781  // See for more information: http://support.microsoft.com/kb/323308
1782  'Cache-Control' => '',
1783  ];
1784 
1785  return new ‪Response($stream, 200, $headers);
1786  }
1787 
1799  public function ‪setFileContents(‪AbstractFile $file, $contents)
1800  {
1801  // Check if user is allowed to edit
1802  $this->‪assureFileWritePermissions($file);
1803  $this->‪emitPreFileSetContentsSignal($file, $contents);
1804  // Call driver method to update the file and update file index entry afterwards
1805  $result = $this->driver->setFileContents($file->‪getIdentifier(), $contents);
1806  if ($file instanceof ‪File) {
1807  $this->‪getIndexer()->updateIndexEntry($file);
1808  }
1809  $this->‪emitPostFileSetContentsSignal($file, $contents);
1810  return $result;
1811  }
1812 
1825  public function ‪createFile($fileName, ‪Folder $targetFolderObject)
1826  {
1827  $this->‪assureFileAddPermissions($targetFolderObject, $fileName);
1828  $this->‪emitPreFileCreateSignal($fileName, $targetFolderObject);
1829  $newFileIdentifier = $this->driver->createFile($fileName, $targetFolderObject->‪getIdentifier());
1830  $this->‪emitPostFileCreateSignal($newFileIdentifier, $targetFolderObject);
1831  return $this->‪getResourceFactoryInstance()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $newFileIdentifier);
1832  }
1833 
1842  public function ‪deleteFile($fileObject)
1843  {
1844  $this->‪assureFileDeletePermissions($fileObject);
1845 
1846  $this->‪emitPreFileDeleteSignal($fileObject);
1847  $deleted = true;
1848 
1849  if ($this->driver->fileExists($fileObject->getIdentifier())) {
1850  // Disable permission check to find nearest recycler and move file without errors
1851  $currentPermissions = ‪$this->evaluatePermissions;
1852  $this->evaluatePermissions = false;
1853 
1854  $recyclerFolder = $this->‪getNearestRecyclerFolder($fileObject);
1855  if ($recyclerFolder === null) {
1856  $result = $this->driver->deleteFile($fileObject->getIdentifier());
1857  } else {
1858  $result = $this->‪moveFile($fileObject, $recyclerFolder);
1859  $deleted = false;
1860  }
1861 
1862  $this->evaluatePermissions = $currentPermissions;
1863 
1864  if (!$result) {
1865  throw new Exception\FileOperationErrorException('Deleting the file "' . $fileObject->getIdentifier() . '\' failed.', 1329831691);
1866  }
1867  }
1868  // Mark the file object as deleted
1869  if ($deleted && $fileObject instanceof AbstractFile) {
1870  $fileObject->setDeleted();
1871  }
1872 
1873  $this->emitPostFileDeleteSignal($fileObject);
1874 
1875  return true;
1876  }
1877 
1892  public function copyFile(FileInterface $file, Folder $targetFolder, $targetFileName = null, $conflictMode = DuplicationBehavior::RENAME)
1893  {
1894  $conflictMode = DuplicationBehavior::cast($conflictMode);
1895  if ($targetFileName === null) {
1896  $targetFileName = $file->getName();
1897  }
1898  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
1899  $this->assureFileCopyPermissions($file, $targetFolder, $sanitizedTargetFileName);
1900  $this->emitPreFileCopySignal($file, $targetFolder);
1901  // File exists and we should abort, let's abort
1902  if ($conflictMode->equals(‪DuplicationBehavior::CANCEL) && $targetFolder->hasFile($sanitizedTargetFileName)) {
1903  throw new Exception\ExistingTargetFileNameException('The target file already exists.', 1320291064);
1904  }
1905  // File exists and we should find another name, let's find another one
1906  if ($conflictMode->equals(‪DuplicationBehavior::RENAME) && $targetFolder->hasFile($sanitizedTargetFileName)) {
1907  $sanitizedTargetFileName = $this->getUniqueName($targetFolder, $sanitizedTargetFileName);
1908  }
1909  $sourceStorage = $file->‪getStorage();
1910  // Call driver method to create a new file from an existing file object,
1911  // and return the new file object
1912  if ($sourceStorage === $this) {
1913  $newFileObjectIdentifier = $this->driver->copyFileWithinStorage($file->‪getIdentifier(), $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1914  } else {
1915  $tempPath = $file->‪getForLocalProcessing();
1916  $newFileObjectIdentifier = $this->driver->addFile($tempPath, $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1917  }
1918  $newFileObject = $this->‪getResourceFactoryInstance()->‪getFileObjectByStorageAndIdentifier($this->‪getUid(), $newFileObjectIdentifier);
1919  $this->‪emitPostFileCopySignal($file, $targetFolder);
1920  return $newFileObject;
1921  }
1922 
1938  public function ‪moveFile($file, $targetFolder, $targetFileName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
1939  {
1940  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
1941  if ($targetFileName === null) {
1942  $targetFileName = $file->‪getName();
1943  }
1944  $originalFolder = $file->‪getParentFolder();
1945  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
1946  $this->‪assureFileMovePermissions($file, $targetFolder, $sanitizedTargetFileName);
1947  if ($targetFolder->hasFile($sanitizedTargetFileName)) {
1948  // File exists and we should abort, let's abort
1949  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
1950  $sanitizedTargetFileName = $this->‪getUniqueName($targetFolder, $sanitizedTargetFileName);
1951  } elseif ($conflictMode->equals(‪DuplicationBehavior::CANCEL)) {
1952  throw new Exception\ExistingTargetFileNameException('The target file already exists', 1329850997);
1953  }
1954  }
1955  $this->‪emitPreFileMoveSignal($file, $targetFolder, $sanitizedTargetFileName);
1956  $sourceStorage = $file->‪getStorage();
1957  // Call driver method to move the file and update the index entry
1958  try {
1959  if ($sourceStorage === $this) {
1960  $newIdentifier = $this->driver->moveFileWithinStorage($file->‪getIdentifier(), $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1961  if (!$file instanceof AbstractFile) {
1962  throw new \RuntimeException('The given file is not of type AbstractFile.', 1384209025);
1963  }
1964  $file->‪updateProperties(['identifier' => $newIdentifier]);
1965  } else {
1966  $tempPath = $file->‪getForLocalProcessing();
1967  $newIdentifier = $this->driver->addFile($tempPath, $targetFolder->getIdentifier(), $sanitizedTargetFileName);
1968 
1969  // Disable permission check to find nearest recycler and move file without errors
1970  $currentPermissions = $sourceStorage->evaluatePermissions;
1971  $sourceStorage->evaluatePermissions = false;
1972 
1973  $recyclerFolder = $sourceStorage->getNearestRecyclerFolder($file);
1974  if ($recyclerFolder === null) {
1975  $sourceStorage->driver->deleteFile($file->‪getIdentifier());
1976  } else {
1977  $sourceStorage->moveFile($file, $recyclerFolder);
1978  }
1979  $sourceStorage->evaluatePermissions = $currentPermissions;
1980  if ($file instanceof File) {
1981  $file->‪updateProperties(['storage' => $this->‪getUid(), 'identifier' => $newIdentifier]);
1982  }
1983  }
1984  $this->‪getIndexer()->updateIndexEntry($file);
1985  } catch (\‪TYPO3\CMS\Core\Exception $e) {
1986  echo $e->getMessage();
1987  }
1988  $this->‪emitPostFileMoveSignal($file, $targetFolder, $originalFolder);
1989  return $file;
1990  }
1991 
2001  public function ‪renameFile($file, $targetFileName, $conflictMode = ‪DuplicationBehavior::RENAME)
2002  {
2003  // The name should be different from the current.
2004  if ($file->‪getName() === $targetFileName) {
2005  return $file;
2006  }
2007  $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
2008  $this->‪assureFileRenamePermissions($file, $sanitizedTargetFileName);
2009  $this->‪emitPreFileRenameSignal($file, $sanitizedTargetFileName);
2010 
2011  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2012 
2013  // Call driver method to rename the file and update the index entry
2014  try {
2015  $newIdentifier = $this->driver->renameFile($file->‪getIdentifier(), $sanitizedTargetFileName);
2016  if ($file instanceof File) {
2017  $file->‪updateProperties(['identifier' => $newIdentifier]);
2018  }
2019  $this->‪getIndexer()->updateIndexEntry($file);
2020  } catch (ExistingTargetFileNameException $exception) {
2021  if ($conflictMode->equals(‪DuplicationBehavior::RENAME)) {
2022  $newName = $this->‪getUniqueName($file->‪getParentFolder(), $sanitizedTargetFileName);
2023  $file = $this->‪renameFile($file, $newName);
2024  } elseif ($conflictMode->equals(‪DuplicationBehavior::CANCEL)) {
2025  throw $exception;
2026  } elseif ($conflictMode->equals(‪DuplicationBehavior::REPLACE)) {
2027  $sourceFileIdentifier = substr($file->‪getCombinedIdentifier(), 0, strrpos($file->‪getCombinedIdentifier(), '/') + 1) . $targetFileName;
2028  $sourceFile = $this->‪getResourceFactoryInstance()->‪getFileObjectFromCombinedIdentifier($sourceFileIdentifier);
2029  $file = $this->‪replaceFile($sourceFile, ‪Environment::getPublicPath() . '/' . $file->‪getPublicUrl());
2030  }
2031  } catch (\RuntimeException $e) {
2032  }
2033 
2034  $this->‪emitPostFileRenameSignal($file, $sanitizedTargetFileName);
2035 
2036  return $file;
2037  }
2038 
2050  public function ‪replaceFile(‪FileInterface $file, $localFilePath)
2051  {
2052  $this->‪assureFileReplacePermissions($file);
2053  if (!file_exists($localFilePath)) {
2054  throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1325842622);
2055  }
2056  $this->‪emitPreFileReplaceSignal($file, $localFilePath);
2057  $this->driver->replaceFile($file->‪getIdentifier(), $localFilePath);
2058  if ($file instanceof File) {
2059  $this->‪getIndexer()->updateIndexEntry($file);
2060  }
2061  if ($this->‪autoExtractMetadataEnabled()) {
2062  $this->‪getIndexer()->extractMetaData($file);
2063  }
2064  $this->‪emitPostFileReplaceSignal($file, $localFilePath);
2065 
2066  return $file;
2067  }
2068 
2078  public function ‪addUploadedFile(array $uploadedFileData, ‪Folder $targetFolder = null, $targetFileName = null, $conflictMode = ‪DuplicationBehavior::CANCEL)
2079  {
2080  $conflictMode = ‪DuplicationBehavior::cast($conflictMode);
2081  $localFilePath = $uploadedFileData['tmp_name'];
2082  if ($targetFolder === null) {
2083  $targetFolder = $this->‪getDefaultFolder();
2084  }
2085  if ($targetFileName === null) {
2086  $targetFileName = $uploadedFileData['name'];
2087  }
2088  $targetFileName = $this->driver->sanitizeFileName($targetFileName);
2089 
2090  $this->‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileData['size']);
2091  if ($this->‪hasFileInFolder($targetFileName, $targetFolder) && $conflictMode->equals(‪DuplicationBehavior::REPLACE)) {
2092  $file = $this->‪getFileInFolder($targetFileName, $targetFolder);
2093  $resultObject = $this->‪replaceFile($file, $localFilePath);
2094  } else {
2095  $resultObject = $this->‪addFile($localFilePath, $targetFolder, $targetFileName, (string)$conflictMode);
2096  }
2097  return $resultObject;
2098  }
2099 
2100  /********************
2101  * FOLDER ACTIONS
2102  ********************/
2109  protected function ‪getAllFileObjectsInFolder(Folder $folder)
2110  {
2111  $files = [];
2112  $folderQueue = [$folder];
2113  while (!empty($folderQueue)) {
2114  $folder = array_shift($folderQueue);
2115  foreach ($folder->getSubfolders() as $subfolder) {
2116  $folderQueue[] = $subfolder;
2117  }
2118  foreach ($folder->getFiles() as $file) {
2120  $files[$file->getIdentifier()] = $file;
2121  }
2122  }
2123 
2124  return $files;
2125  }
2126 
2141  public function ‪moveFolder(Folder $folderToMove, Folder $targetParentFolder, $newFolderName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2142  {
2143  // @todo add tests
2144  $originalFolder = $folderToMove->‪getParentFolder();
2145  $this->‪assureFolderMovePermissions($folderToMove, $targetParentFolder);
2146  $sourceStorage = $folderToMove->getStorage();
2147  $returnObject = null;
2148  $sanitizedNewFolderName = $this->driver->sanitizeFileName($newFolderName ?: $folderToMove->getName());
2149  // @todo check if folder already exists in $targetParentFolder, handle this conflict then
2150  $this->‪emitPreFolderMoveSignal($folderToMove, $targetParentFolder, $sanitizedNewFolderName);
2151  // Get all file objects now so we are able to update them after moving the folder
2152  $fileObjects = $this->‪getAllFileObjectsInFolder($folderToMove);
2153  if ($sourceStorage === $this) {
2154  if ($this->‪isWithinFolder($folderToMove, $targetParentFolder)) {
2155  throw new InvalidTargetFolderException(
2156  sprintf(
2157  'Cannot move folder "%s" into target folder "%s", because the target folder is already within the folder to be moved!',
2158  $folderToMove->getName(),
2159  $targetParentFolder->getName()
2160  ),
2161  1422723050
2162  );
2163  }
2164  $fileMappings = $this->driver->moveFolderWithinStorage($folderToMove->getIdentifier(), $targetParentFolder->getIdentifier(), $sanitizedNewFolderName);
2165  } else {
2166  $fileMappings = $this->‪moveFolderBetweenStorages($folderToMove, $targetParentFolder, $sanitizedNewFolderName);
2167  }
2168  // Update the identifier and storage of all file objects
2169  foreach ($fileObjects as $oldIdentifier => $fileObject) {
2170  $newIdentifier = $fileMappings[$oldIdentifier];
2171  $fileObject->updateProperties(['storage' => $this->‪getUid(), 'identifier' => $newIdentifier]);
2172  $this->‪getIndexer()->updateIndexEntry($fileObject);
2173  }
2174  $returnObject = $this->‪getFolder($fileMappings[$folderToMove->getIdentifier()]);
2175  $this->‪emitPostFolderMoveSignal($folderToMove, $targetParentFolder, $returnObject->getName(), $originalFolder);
2176  return $returnObject;
2177  }
2178 
2187  protected function ‪moveFolderBetweenStorages(Folder $folderToMove, Folder $targetParentFolder, $newFolderName)
2188  {
2189  throw new ‪NotImplementedMethodException('Not yet implemented', 1476046361);
2190  }
2191 
2202  public function ‪copyFolder(‪FolderInterface $folderToCopy, ‪FolderInterface $targetParentFolder, $newFolderName = null, $conflictMode = ‪DuplicationBehavior::RENAME)
2203  {
2204  // @todo implement the $conflictMode handling
2205  $this->‪assureFolderCopyPermissions($folderToCopy, $targetParentFolder);
2206  $returnObject = null;
2207  $sanitizedNewFolderName = $this->driver->sanitizeFileName($newFolderName ?: $folderToCopy->‪getName());
2208  if ($folderToCopy instanceof ‪Folder && $targetParentFolder instanceof ‪Folder) {
2209  $this->‪emitPreFolderCopySignal($folderToCopy, $targetParentFolder, $sanitizedNewFolderName);
2210  }
2211  $sourceStorage = $folderToCopy->‪getStorage();
2212  // call driver method to move the file
2213  // that also updates the file object properties
2214  if ($sourceStorage === $this) {
2215  if ($this->‪isWithinFolder($folderToCopy, $targetParentFolder)) {
2216  throw new InvalidTargetFolderException(
2217  sprintf(
2218  'Cannot copy folder "%s" into target folder "%s", because the target folder is already within the folder to be copied!',
2219  $folderToCopy->‪getName(),
2220  $targetParentFolder->‪getName()
2221  ),
2222  1422723059
2223  );
2224  }
2225  $this->driver->copyFolderWithinStorage($folderToCopy->‪getIdentifier(), $targetParentFolder->‪getIdentifier(), $sanitizedNewFolderName);
2226  $returnObject = $this->‪getFolder($targetParentFolder->‪getSubfolder($sanitizedNewFolderName)->‪getIdentifier());
2227  } else {
2228  $this->‪copyFolderBetweenStorages($folderToCopy, $targetParentFolder, $sanitizedNewFolderName);
2229  }
2230  $this->‪emitPostFolderCopySignal($folderToCopy, $targetParentFolder, $returnObject->‪getName());
2231  return $returnObject;
2232  }
2233 
2242  protected function ‪copyFolderBetweenStorages(‪Folder $folderToCopy, ‪Folder $targetParentFolder, $newFolderName)
2243  {
2244  throw new ‪NotImplementedMethodException('Not yet implemented.', 1476046386);
2245  }
2246 
2256  public function ‪renameFolder($folderObject, $newName)
2257  {
2258 
2259  // Renaming the folder should check if the parent folder is writable
2260  // We cannot do this however because we cannot extract the parent folder from a folder currently
2261  if (!$this->‪checkFolderActionPermission('rename', $folderObject)) {
2262  throw new Exception\InsufficientUserPermissionsException('You are not allowed to rename the folder "' . $folderObject->getIdentifier() . '\'', 1357811441);
2263  }
2264 
2265  $sanitizedNewName = $this->driver->sanitizeFileName($newName);
2266  $returnObject = null;
2267  if ($this->driver->folderExistsInFolder($sanitizedNewName, $folderObject->getIdentifier())) {
2268  throw new \InvalidArgumentException('The folder ' . $sanitizedNewName . ' already exists in folder ' . $folderObject->getIdentifier(), 1325418870);
2269  }
2270 
2271  $this->‪emitPreFolderRenameSignal($folderObject, $sanitizedNewName);
2272 
2273  $fileObjects = $this->‪getAllFileObjectsInFolder($folderObject);
2274  $fileMappings = $this->driver->renameFolder($folderObject->getIdentifier(), $sanitizedNewName);
2275  // Update the identifier of all file objects
2276  foreach ($fileObjects as $oldIdentifier => $fileObject) {
2277  $newIdentifier = $fileMappings[$oldIdentifier];
2278  $fileObject->updateProperties(['identifier' => $newIdentifier]);
2279  $this->‪getIndexer()->updateIndexEntry($fileObject);
2280  }
2281  $returnObject = $this->‪getFolder($fileMappings[$folderObject->getIdentifier()]);
2282 
2283  $this->‪emitPostFolderRenameSignal($folderObject, $returnObject->getName(), $returnObject);
2284 
2285  return $returnObject;
2286  }
2287 
2300  public function ‪deleteFolder($folderObject, $deleteRecursively = false)
2301  {
2302  $isEmpty = $this->driver->isFolderEmpty($folderObject->getIdentifier());
2303  $this->‪assureFolderDeletePermission($folderObject, $deleteRecursively && !$isEmpty);
2304  if (!$isEmpty && !$deleteRecursively) {
2305  throw new \RuntimeException('Could not delete folder "' . $folderObject->getIdentifier() . '" because it is not empty.', 1325952534);
2306  }
2307 
2308  $this->‪emitPreFolderDeleteSignal($folderObject);
2309 
2310  foreach ($this->‪getFilesInFolder($folderObject, 0, 0, false, $deleteRecursively) as $file) {
2311  $this->‪deleteFile($file);
2312  }
2313 
2314  $result = $this->driver->deleteFolder($folderObject->getIdentifier(), $deleteRecursively);
2315 
2316  $this->‪emitPostFolderDeleteSignal($folderObject);
2318  return $result;
2319  }
2320 
2331  public function ‪getFolderInFolder($folderName, ‪Folder $parentFolder, $returnInaccessibleFolderObject = false)
2332  {
2333  $folderIdentifier = $this->driver->getFolderInFolder($folderName, $parentFolder->‪getIdentifier());
2334  return $this->‪getFolder($folderIdentifier, $returnInaccessibleFolderObject);
2335  }
2336 
2351  public function ‪getFoldersInFolder(Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
2352  {
2353  $filters = $useFilters == true ? $this->fileAndFolderNameFilters : [];
2354 
2355  $folderIdentifiers = $this->driver->getFoldersInFolder($folder->getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev);
2356 
2357  // Exclude processing folders
2358  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
2359  $processingIdentifier = ‪$processingFolder->‪getIdentifier();
2360  if (isset($folderIdentifiers[$processingIdentifier])) {
2361  unset($folderIdentifiers[$processingIdentifier]);
2362  }
2363  }
2364  $folders = [];
2365  foreach ($folderIdentifiers as $folderIdentifier) {
2366  $folders[$folderIdentifier] = $this->‪getFolder($folderIdentifier, true);
2367  }
2368  return $folders;
2369  }
2370 
2378  public function ‪countFoldersInFolder(Folder $folder, $useFilters = true, $recursive = false)
2379  {
2380  $this->‪assureFolderReadPermission($folder);
2381  $filters = $useFilters ? $this->fileAndFolderNameFilters : [];
2382  return $this->driver->countFoldersInFolder($folder->getIdentifier(), $recursive, $filters);
2383  }
2384 
2391  public function ‪hasFolder($identifier)
2392  {
2394  return $this->driver->folderExists($identifier);
2395  }
2396 
2404  public function ‪hasFolderInFolder($folderName, Folder $folder)
2405  {
2406  $this->‪assureFolderReadPermission($folder);
2407  return $this->driver->folderExistsInFolder($folderName, $folder->getIdentifier());
2408  }
2423  public function ‪createFolder($folderName, ‪Folder $parentFolder = null)
2424  {
2425  if ($parentFolder === null) {
2426  $parentFolder = $this->‪getRootLevelFolder();
2427  } elseif (!$this->driver->folderExists($parentFolder->getIdentifier())) {
2428  throw new \InvalidArgumentException('Parent folder "' . $parentFolder->getIdentifier() . '" does not exist.', 1325689164);
2429  }
2430  if (!$this->‪checkFolderActionPermission('add', $parentFolder)) {
2431  throw new Exception\InsufficientFolderWritePermissionsException('You are not allowed to create directories in the folder "' . $parentFolder->getIdentifier() . '"', 1323059807);
2432  }
2433  if ($this->driver->folderExistsInFolder($folderName, $parentFolder->getIdentifier())) {
2434  throw new Exception\ExistingTargetFolderException('Folder "' . $folderName . '" already exists.', 1423347324);
2435  }
2436 
2437  $this->‪emitPreFolderAddSignal($parentFolder, $folderName);
2438 
2439  $newFolder = $this->‪getDriver()->createFolder($folderName, $parentFolder->getIdentifier(), true);
2440  $newFolder = $this->‪getFolder($newFolder);
2441 
2442  $this->‪emitPostFolderAddSignal($newFolder);
2443 
2444  return $newFolder;
2445  }
2446 
2453  public function ‪getFolderInfo(‪Folder $folder)
2454  {
2455  return $this->driver->getFolderInfoByIdentifier($folder->‪getIdentifier());
2456  }
2457 
2463  public function ‪getDefaultFolder()
2464  {
2465  return $this->‪getFolder($this->driver->getDefaultFolder());
2466  }
2467 
2476  public function ‪getFolder($identifier, $returnInaccessibleFolderObject = false)
2477  {
2478  $data = $this->driver->getFolderInfoByIdentifier($identifier);
2479  $folder = $this->‪getResourceFactoryInstance()->‪createFolderObject($this, $data['identifier'] ?? null, $data['name'] ?? null);
2480 
2481  try {
2482  $this->‪assureFolderReadPermission($folder);
2483  } catch (Exception\InsufficientFolderAccessPermissionsException $e) {
2484  $folder = null;
2485  if ($returnInaccessibleFolderObject) {
2486  // if parent folder is readable return inaccessible folder object
2487  $parentPermissions = $this->driver->getPermissions($this->driver->getParentFolderIdentifierOfIdentifier($identifier));
2488  if ($parentPermissions['r']) {
2489  $folder = GeneralUtility::makeInstance(
2490  InaccessibleFolder::class,
2491  $this,
2492  $data['identifier'],
2493  $data['name']
2494  );
2495  }
2496  }
2498  if ($folder === null) {
2499  throw $e;
2500  }
2501  }
2502  return $folder;
2503  }
2504 
2511  public function ‪isWithinProcessingFolder($identifier)
2512  {
2513  $inProcessingFolder = false;
2514  foreach ($this->‪getProcessingFolders() as ‪$processingFolder) {
2515  if ($this->driver->isWithin(‪$processingFolder->‪getIdentifier(), $identifier)) {
2516  $inProcessingFolder = true;
2517  break;
2518  }
2519  }
2520  return $inProcessingFolder;
2521  }
2522 
2531  public function ‪isWithinFolder(Folder $folder, ResourceInterface $resource)
2532  {
2533  if ($folder->getStorage() !== $this) {
2534  throw new \InvalidArgumentException('Given folder "' . $folder->getIdentifier() . '" is not part of this storage!', 1422709241);
2535  }
2536  if ($folder->getStorage() !== $resource->getStorage()) {
2537  return false;
2538  }
2539  return $this->driver->isWithin($folder->getIdentifier(), $resource->getIdentifier());
2540  }
2541 
2550  public function ‪getRootLevelFolder($respectFileMounts = true)
2551  {
2552  if ($respectFileMounts && !empty($this->fileMounts)) {
2553  $mount = reset($this->fileMounts);
2554  return $mount['folder'];
2555  }
2556  return $this->‪getResourceFactoryInstance()->‪createFolderObject($this, $this->driver->getRootLevelFolder(), '');
2557  }
2558 
2566  protected function ‪emitSanitizeFileNameSignal($fileName, ‪Folder $targetFolder)
2567  {
2568  list($fileName) = $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_SanitizeFileName, [$fileName, $targetFolder, $this, $this->driver]);
2569  return $fileName;
2570  }
2571 
2580  protected function ‪emitPreFileAddSignal($targetFileName, ‪Folder $targetFolder, $sourceFilePath)
2581  {
2582  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFileAdd, [&$targetFileName, $targetFolder, $sourceFilePath, $this, $this->driver]);
2583  return $targetFileName;
2584  }
2585 
2592  protected function ‪emitPostFileAddSignal(FileInterface $file, Folder $targetFolder)
2593  {
2594  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFileAdd, [$file, $targetFolder]);
2595  }
2596 
2603  protected function ‪emitPreFileCopySignal(FileInterface $file, Folder $targetFolder)
2604  {
2605  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFileCopy, [$file, $targetFolder]);
2606  }
2607 
2614  protected function ‪emitPostFileCopySignal(FileInterface $file, Folder $targetFolder)
2615  {
2616  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFileCopy, [$file, $targetFolder]);
2617  }
2618 
2626  protected function ‪emitPreFileMoveSignal(FileInterface $file, Folder $targetFolder, string $targetFileName)
2627  {
2628  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFileMove, [$file, $targetFolder, $targetFileName]);
2629  }
2630 
2638  protected function ‪emitPostFileMoveSignal(FileInterface $file, Folder $targetFolder, FolderInterface $originalFolder)
2639  {
2640  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFileMove, [$file, $targetFolder, $originalFolder]);
2641  }
2642 
2649  protected function ‪emitPreFileRenameSignal(FileInterface $file, $targetFolder)
2650  {
2651  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFileRename, [$file, $targetFolder]);
2652  }
2653 
2660  protected function ‪emitPostFileRenameSignal(FileInterface $file, $sanitizedTargetFileName)
2661  {
2662  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFileRename, [$file, $sanitizedTargetFileName]);
2663  }
2664 
2671  protected function ‪emitPreFileReplaceSignal(FileInterface $file, $localFilePath)
2672  {
2673  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFileReplace, [$file, $localFilePath]);
2674  }
2675 
2682  protected function ‪emitPostFileReplaceSignal(FileInterface $file, $localFilePath)
2683  {
2684  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFileReplace, [$file, $localFilePath]);
2685  }
2686 
2693  protected function ‪emitPreFileCreateSignal(string $fileName, Folder $targetFolder)
2694  {
2695  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFileCreate, [$fileName, $targetFolder]);
2696  }
2697 
2704  protected function ‪emitPostFileCreateSignal($newFileIdentifier, Folder $targetFolder)
2705  {
2706  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFileCreate, [$newFileIdentifier, $targetFolder]);
2707  }
2708 
2714  protected function ‪emitPreFileDeleteSignal(FileInterface $file)
2715  {
2716  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFileDelete, [$file]);
2717  }
2718 
2724  protected function ‪emitPostFileDeleteSignal(FileInterface $file)
2725  {
2726  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFileDelete, [$file]);
2727  }
2728 
2735  protected function ‪emitPreFileSetContentsSignal(FileInterface $file, $content)
2736  {
2737  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFileSetContents, [$file, $content]);
2738  }
2739 
2746  protected function ‪emitPostFileSetContentsSignal(FileInterface $file, $content)
2747  {
2748  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFileSetContents, [$file, $content]);
2749  }
2750 
2757  protected function ‪emitPreFolderAddSignal(Folder $targetFolder, $name)
2758  {
2759  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFolderAdd, [$targetFolder, $name]);
2760  }
2761 
2767  protected function ‪emitPostFolderAddSignal(Folder $folder)
2768  {
2769  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFolderAdd, [$folder]);
2770  }
2771 
2779  protected function ‪emitPreFolderCopySignal(Folder $folder, Folder $targetFolder, $newName)
2780  {
2781  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFolderCopy, [$folder, $targetFolder, $newName]);
2782  }
2783 
2791  protected function ‪emitPostFolderCopySignal(Folder $folder, Folder $targetFolder, $newName)
2792  {
2793  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFolderCopy, [$folder, $targetFolder, $newName]);
2794  }
2795 
2803  protected function ‪emitPreFolderMoveSignal(Folder $folder, Folder $targetFolder, $newName)
2804  {
2805  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFolderMove, [$folder, $targetFolder, $newName]);
2806  }
2807 
2816  protected function ‪emitPostFolderMoveSignal(Folder $folder, Folder $targetFolder, $newName, Folder $originalFolder)
2817  {
2818  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFolderMove, [$folder, $targetFolder, $newName, $originalFolder]);
2819  }
2820 
2827  protected function ‪emitPreFolderRenameSignal(Folder $folder, $newName)
2828  {
2829  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFolderRename, [$folder, $newName]);
2830  }
2831 
2839  protected function ‪emitPostFolderRenameSignal(Folder $folder, $newName, Folder $newFolder)
2840  {
2841  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFolderRename, [$folder, $newName, $newFolder]);
2842  }
2843 
2849  protected function ‪emitPreFolderDeleteSignal(Folder $folder)
2850  {
2851  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreFolderDelete, [$folder]);
2852  }
2853 
2859  protected function ‪emitPostFolderDeleteSignal(Folder $folder)
2860  {
2861  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PostFolderDelete, [$folder]);
2862  }
2863 
2871  protected function ‪emitPreGeneratePublicUrlSignal(ResourceInterface $resourceObject, $relativeToCurrentScript, array $urlData)
2872  {
2873  $this->‪getSignalSlotDispatcher()->‪dispatch(self::class, self::SIGNAL_PreGeneratePublicUrl, [$this, $this->driver, $resourceObject, $relativeToCurrentScript, $urlData]);
2874  }
2875 
2891  protected function ‪getUniqueName(FolderInterface $folder, $theFile, $dontCheckForUnique = false)
2892  {
2893  $maxNumber = 99;
2894  // Fetches info about path, name, extension of $theFile
2895  $origFileInfo = ‪PathUtility::pathinfo($theFile);
2896  // Check if the file exists and if not - return the fileName...
2897  // The destinations file
2898  $theDestFile = $origFileInfo['basename'];
2899  // If the file does NOT exist we return this fileName
2900  if (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier()) || $dontCheckForUnique) {
2901  return $theDestFile;
2902  }
2903  // Well the fileName in its pure form existed. Now we try to append
2904  // numbers / unique-strings and see if we can find an available fileName
2905  // This removes _xx if appended to the file
2906  $theTempFileBody = preg_replace('/_[0-9][0-9]$/', '', $origFileInfo['filename']);
2907  $theOrigExt = $origFileInfo['extension'] ? '.' . $origFileInfo['extension'] : '';
2908  for ($a = 1; $a <= $maxNumber + 1; $a++) {
2909  // First we try to append numbers
2910  if ($a <= $maxNumber) {
2911  $insert = '_' . sprintf('%02d', $a);
2912  } else {
2913  $insert = '_' . substr(md5(uniqid('', true)), 0, 6);
2914  }
2915  $theTestFile = $theTempFileBody . $insert . $theOrigExt;
2916  // The destinations file
2917  $theDestFile = $theTestFile;
2918  // If the file does NOT exist we return this fileName
2919  if (!$this->driver->fileExistsInFolder($theDestFile, $folder->getIdentifier())) {
2920  return $theDestFile;
2921  }
2922  }
2923  throw new \RuntimeException('Last possible name "' . $theDestFile . '" is already taken.', 1325194291);
2924  }
2925 
2931  protected function ‪getSignalSlotDispatcher()
2932  {
2933  if (!isset($this->signalSlotDispatcher)) {
2934  $this->signalSlotDispatcher = $this->‪getObjectManager()->‪get(Dispatcher::class);
2935  }
2937  }
2944  protected function ‪getObjectManager()
2945  {
2946  return GeneralUtility::makeInstance(ObjectManager::class);
2947  }
2948 
2952  protected function ‪getFileFactory()
2953  {
2954  return GeneralUtility::makeInstance(ResourceFactory::class);
2955  }
2956 
2960  protected function ‪getFileIndexRepository()
2961  {
2963  }
2964 
2968  protected function ‪getFileProcessingService()
2969  {
2970  if (!$this->fileProcessingService) {
2971  $this->fileProcessingService = GeneralUtility::makeInstance(Service\FileProcessingService::class, $this, $this->driver);
2972  }
2974  }
2975 
2982  public function ‪getRole(‪FolderInterface $folder)
2983  {
2984  $folderRole = ‪FolderInterface::ROLE_DEFAULT;
2985  $identifier = $folder->‪getIdentifier();
2986  if (method_exists($this->driver, 'getRole')) {
2987  $folderRole = $this->driver->getRole($folder->‪getIdentifier());
2988  }
2989  if (isset($this->fileMounts[$identifier])) {
2990  $folderRole = ‪FolderInterface::ROLE_MOUNT;
2991 
2992  if (!empty($this->fileMounts[$identifier]['read_only'])) {
2994  }
2995  if ($this->fileMounts[$identifier]['user_mount']) {
2997  }
2998  }
2999  if ($folder instanceof ‪Folder && $this->‪isProcessingFolder($folder)) {
3001  }
3002 
3003  return $folderRole;
3004  }
3005 
3013  public function ‪getProcessingFolder(File $file = null)
3014  {
3015  // If a file is given, make sure to return the processing folder of the correct storage
3016  if ($file !== null && $file->getStorage()->getUid() !== $this->getUid()) {
3017  return $file->‪getStorage()->‪getProcessingFolder($file);
3018  }
3019  if (!isset($this->processingFolder)) {
3021  if (!empty($this->storageRecord['processingfolder'])) {
3022  ‪$processingFolder = $this->storageRecord['processingfolder'];
3023  }
3024  try {
3025  if (strpos(‪$processingFolder, ':') !== false) {
3026  list($storageUid, $processingFolderIdentifier) = explode(':', ‪$processingFolder, 2);
3027  $storage = $this->‪getResourceFactoryInstance()->‪getStorageObject($storageUid);
3028  if ($storage->hasFolder($processingFolderIdentifier)) {
3029  $this->processingFolder = $storage->‪getFolder($processingFolderIdentifier);
3030  } else {
3031  $rootFolder = $storage->getRootLevelFolder(false);
3032  $currentEvaluatePermissions = $storage->getEvaluatePermissions();
3033  $storage->setEvaluatePermissions(false);
3034  $this->processingFolder = $storage->‪createFolder(
3035  ltrim($processingFolderIdentifier, '/'),
3036  $rootFolder
3037  );
3038  $storage->setEvaluatePermissions($currentEvaluatePermissions);
3039  }
3040  } else {
3041  if ($this->driver->folderExists(‪$processingFolder) === false) {
3042  $rootFolder = $this->‪getRootLevelFolder(false);
3043  try {
3044  $currentEvaluatePermissions = ‪$this->evaluatePermissions;
3045  $this->evaluatePermissions = false;
3046  $this->processingFolder = $this->‪createFolder(
3047  $processingFolder,
3048  $rootFolder
3049  );
3050  $this->evaluatePermissions = $currentEvaluatePermissions;
3051  } catch (\InvalidArgumentException $e) {
3052  $this->processingFolder = GeneralUtility::makeInstance(
3053  InaccessibleFolder::class,
3054  $this,
3057  );
3058  }
3059  } else {
3060  $data = $this->driver->getFolderInfoByIdentifier(‪$processingFolder);
3061  $this->processingFolder = $this->‪getResourceFactoryInstance()->‪createFolderObject($this, $data['identifier'], $data['name']);
3062  }
3063  }
3064  } catch (Exception\InsufficientFolderWritePermissionsException $e) {
3065  $this->processingFolder = GeneralUtility::makeInstance(
3066  InaccessibleFolder::class,
3067  $this,
3070  );
3071  } catch (Exception\ResourcePermissionsUnavailableException $e) {
3072  $this->processingFolder = GeneralUtility::makeInstance(
3073  InaccessibleFolder::class,
3074  $this,
3077  );
3078  }
3079  }
3080 
3082  if (!empty($file)) {
3084  }
3085  return ‪$processingFolder;
3086  }
3087 
3097  protected function ‪getNestedProcessingFolder(File $file, Folder $rootProcessingFolder)
3098  {
3099  ‪$processingFolder = $rootProcessingFolder;
3100  $nestedFolderNames = $this->‪getNamesForNestedProcessingFolder(
3101  $file->getIdentifier(),
3102  self::PROCESSING_FOLDER_LEVELS
3103  );
3104 
3105  try {
3106  foreach ($nestedFolderNames as $folderName) {
3107  if (‪$processingFolder->‪hasFolder($folderName)) {
3109  } else {
3110  $currentEvaluatePermissions = ‪$processingFolder->‪getStorage()->‪getEvaluatePermissions();
3113  ‪$processingFolder->‪getStorage()->‪setEvaluatePermissions($currentEvaluatePermissions);
3114  }
3115  }
3116  } catch (‪Exception\FolderDoesNotExistException $e) {
3117  }
3118 
3119  return ‪$processingFolder;
3120  }
3121 
3129  protected function ‪getNamesForNestedProcessingFolder($fileIdentifier, $levels)
3130  {
3131  $names = [];
3132  if ($levels === 0) {
3133  return $names;
3134  }
3135  $hash = md5($fileIdentifier);
3136  for ($i = 1; $i <= $levels; $i++) {
3137  $names[] = substr($hash, $i, 1);
3138  }
3139  return $names;
3140  }
3141 
3147  public function ‪getDriverType()
3148  {
3149  return $this->storageRecord['driver'];
3150  }
3157  protected function ‪getIndexer()
3158  {
3159  return GeneralUtility::makeInstance(Index\Indexer::class, $this);
3160  }
3161 
3165  public function ‪setDefault(‪$isDefault)
3166  {
3167  $this->‪isDefault = (bool)‪$isDefault;
3168  }
3169 
3173  public function ‪isDefault()
3174  {
3175  return ‪$this->isDefault;
3176  }
3182  {
3184  }
3185 
3191  protected function ‪getBackendUser()
3192  {
3193  return ‪$GLOBALS['BE_USER'];
3194  }
3195 
3207  protected function ‪getNearestRecyclerFolder(‪FileInterface $file)
3208  {
3209  if ($file instanceof ‪ProcessedFile) {
3210  return null;
3211  }
3212  // if the storage is not browsable we cannot fetch the parent folder of the file so no recycler handling is possible
3213  if (!$this->‪isBrowsable()) {
3214  return null;
3215  }
3216 
3217  $recyclerFolder = null;
3218  $folder = $file->‪getParentFolder();
3219 
3220  do {
3221  if ($folder->getRole() === ‪FolderInterface::ROLE_RECYCLER) {
3222  break;
3223  }
3224 
3225  foreach ($folder->‪getSubfolders() as $subFolder) {
3226  if ($subFolder->getRole() === ‪FolderInterface::ROLE_RECYCLER) {
3227  $recyclerFolder = $subFolder;
3228  break;
3229  }
3230  }
3231 
3232  $parentFolder = $folder->‪getParentFolder();
3233  $isFolderLoop = $folder->‪getIdentifier() === $parentFolder->getIdentifier();
3234  $folder = $parentFolder;
3235  } while ($recyclerFolder === null && !$isFolderLoop);
3236 
3237  return $recyclerFolder;
3238  }
3239 }
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileProcessingService
‪Service FileProcessingService getFileProcessingService()
Definition: ResourceStorage.php:2954
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileAndFolderNameFilters
‪array $fileAndFolderNameFilters
Definition: ResourceStorage.php:154
‪TYPO3\CMS\Core\Resource\FolderInterface\getSubfolders
‪Folder[] getSubfolders()
‪TYPO3\CMS\Core\Resource\ResourceStorage\$signalSlotDispatcher
‪Dispatcher $signalSlotDispatcher
Definition: ResourceStorage.php:128
‪TYPO3\CMS\Core\Resource\Search\Result\EmptyFileSearchResult
Definition: EmptyFileSearchResult.php:22
‪TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile
‪File getOriginalFile()
Definition: ProcessedFile.php:293
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasHierarchicalIdentifiers
‪bool hasHierarchicalIdentifiers()
Definition: ResourceStorage.php:350
‪TYPO3\CMS\Core\Resource\ResourceStorage\renameFolder
‪Folder renameFolder($folderObject, $newName)
Definition: ResourceStorage.php:2242
‪TYPO3\CMS\Core\Resource\FileInterface\getExtension
‪string getExtension()
‪TYPO3\CMS\Core\Resource\ResourceStorage\deleteFolder
‪bool deleteFolder($folderObject, $deleteRecursively=false)
Definition: ResourceStorage.php:2286
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository
Definition: FileIndexRepository.php:41
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFolderDeleteSignal
‪emitPreFolderDeleteSignal(Folder $folder)
Definition: ResourceStorage.php:2835
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileAndFolderNameFilter
‪addFileAndFolderNameFilter($filter)
Definition: ResourceStorage.php:1478
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\resetFileAndFolderNameFiltersToDefault
‪resetFileAndFolderNameFiltersToDefault()
Definition: ResourceStorage.php:1450
‪TYPO3\CMS\Core\Resource\ResourceStorage\countFilesInFolder
‪int countFilesInFolder(Folder $folder, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1568
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry
Definition: OnlineMediaHelperRegistry.php:25
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInfo
‪array getFileInfo(FileInterface $fileObject)
Definition: ResourceStorage.php:1421
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFolderCopySignal
‪emitPreFolderCopySignal(Folder $folder, Folder $targetFolder, $newName)
Definition: ResourceStorage.php:2765
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface
Definition: ResourceStorageInterface.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFileDeleteSignal
‪emitPostFileDeleteSignal(FileInterface $file)
Definition: ResourceStorage.php:2710
‪TYPO3\CMS\Core\Resource\ResourceStorage\markAsTemporaryOffline
‪markAsTemporaryOffline()
Definition: ResourceStorage.php:463
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUid
‪int getUid()
Definition: ResourceStorage.php:271
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFolderAddSignal
‪emitPostFolderAddSignal(Folder $folder)
Definition: ResourceStorage.php:2753
‪TYPO3\CMS\Core\Resource\File\setMissing
‪setMissing($missing)
Definition: File.php:344
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:153
‪TYPO3\CMS\Core\Resource\AbstractFile\getPublicUrl
‪string null getPublicUrl($relativeToCurrentScript=false)
Definition: AbstractFile.php:530
‪TYPO3\CMS\Core\Resource\ResourceStorage\setUserPermissions
‪setUserPermissions(array $userPermissions)
Definition: ResourceStorage.php:600
‪TYPO3\CMS\Core\Resource\AbstractFile\getIdentifier
‪string getIdentifier()
Definition: AbstractFile.php:139
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInfoByIdentifier
‪array getFileInfoByIdentifier($identifier, array $propertiesToExtract=[])
Definition: ResourceStorage.php:1434
‪TYPO3\CMS\Core\Resource\ResourceStorage\getEvaluatePermissions
‪bool getEvaluatePermissions()
Definition: ResourceStorage.php:590
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderInFolder
‪Folder InaccessibleFolder getFolderInFolder($folderName, Folder $parentFolder, $returnInaccessibleFolderObject=false)
Definition: ResourceStorage.php:2317
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\CANCEL
‪const CANCEL
Definition: DuplicationBehavior.php:45
‪TYPO3\CMS\Core\Resource\ResourceStorage\getPublicUrl
‪string null getPublicUrl(ResourceInterface $resourceObject, $relativeToCurrentScript=false)
Definition: ResourceStorage.php:1317
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileReplacePermissions
‪assureFileReplacePermissions(FileInterface $file)
Definition: ResourceStorage.php:893
‪TYPO3\CMS\Core\Resource\ResourceStorage\PROCESSING_FOLDER_LEVELS
‪const PROCESSING_FOLDER_LEVELS
Definition: ResourceStorage.php:159
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDefaultFolder
‪Folder getDefaultFolder()
Definition: ResourceStorage.php:2449
‪TYPO3\CMS\Core\Resource\FileInterface
Definition: FileInterface.php:21
‪TYPO3\CMS\Core\Resource\AbstractFile\getForLocalProcessing
‪string getForLocalProcessing($writable=true)
Definition: AbstractFile.php:548
‪TYPO3\CMS\Core\Resource\ResourceStorage\dumpFileContents
‪dumpFileContents(FileInterface $file, $asDownload=false, $alternativeFilename=null, $overrideMimeType=null)
Definition: ResourceStorage.php:1688
‪TYPO3\CMS\Core\Resource\ResourceStorage\setDriver
‪ResourceStorage setDriver(Driver\DriverInterface $driver)
Definition: ResourceStorage.php:240
‪TYPO3\CMS\Core\Resource\AbstractFile\getName
‪string getName()
Definition: AbstractFile.php:159
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFolder
‪Folder moveFolder(Folder $folderToMove, Folder $targetParentFolder, $newFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2127
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFoldersInFolder
‪Folder[] getFoldersInFolder(Folder $folder, $start=0, $maxNumberOfItems=0, $useFilters=true, $recursive=false, $sort='', $sortRev=false)
Definition: ResourceStorage.php:2337
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDriverType
‪string getDriverType()
Definition: ResourceStorage.php:3133
‪TYPO3\CMS\Core\Utility\PathUtility\dirname
‪static string dirname($path)
Definition: PathUtility.php:185
‪TYPO3\CMS\Core\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorage\processFile
‪ProcessedFile processFile(FileInterface $fileObject, $context, array $configuration)
Definition: ResourceStorage.php:1376
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitSanitizeFileNameSignal
‪string emitSanitizeFileNameSignal($fileName, Folder $targetFolder)
Definition: ResourceStorage.php:2552
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFileCreateSignal
‪emitPostFileCreateSignal($newFileIdentifier, Folder $targetFolder)
Definition: ResourceStorage.php:2690
‪TYPO3\CMS\Core\Resource\ResourceStorage\$storageRecord
‪array $storageRecord
Definition: ResourceStorage.php:85
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_DEFAULT
‪const ROLE_DEFAULT
Definition: FolderInterface.php:25
‪TYPO3\CMS\Core\Resource\ResourceStorage\__construct
‪__construct(Driver\DriverInterface $driver, array $storageRecord)
Definition: ResourceStorage.php:167
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFileReplaceSignal
‪emitPostFileReplaceSignal(FileInterface $file, $localFilePath)
Definition: ResourceStorage.php:2668
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileExtensionPermission
‪bool checkFileExtensionPermission($fileName)
Definition: ResourceStorage.php:786
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFilesInFolder
‪File[] getFilesInFolder(Folder $folder, $start=0, $maxNumberOfItems=0, $useFilters=true, $recursive=false, $sort='', $sortRev=false)
Definition: ResourceStorage.php:1521
‪TYPO3\CMS\Core\Resource\ResourceStorage\getStorageRecord
‪array getStorageRecord()
Definition: ResourceStorage.php:229
‪TYPO3
‪TYPO3\CMS\Core\Resource\Index\Indexer
Definition: Indexer.php:33
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessingFolder
‪Folder getProcessingFolder(File $file=null)
Definition: ResourceStorage.php:2999
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileFactory
‪ResourceFactory getFileFactory()
Definition: ResourceStorage.php:2938
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileMount
‪addFileMount($folderIdentifier, $additionalData=[])
Definition: ResourceStorage.php:483
‪TYPO3\CMS\Core\Registry
Definition: Registry.php:32
‪TYPO3\CMS\Core\Resource\ResourceStorage\$configuration
‪array $configuration
Definition: ResourceStorage.php:91
‪TYPO3\CMS\Core\Resource\ResourceStorage\addUploadedFile
‪FileInterface addUploadedFile(array $uploadedFileData, Folder $targetFolder=null, $targetFileName=null, $conflictMode=DuplicationBehavior::CANCEL)
Definition: ResourceStorage.php:2064
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolder
‪Folder InaccessibleFolder getFolder($identifier, $returnInaccessibleFolderObject=false)
Definition: ResourceStorage.php:2462
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderIdentifierFromFileIdentifier
‪string getFolderIdentifierFromFileIdentifier($fileIdentifier)
Definition: ResourceStorage.php:1488
‪TYPO3\CMS\Core\Resource\ResourceStorage\replaceFile
‪FileInterface replaceFile(FileInterface $file, $localFilePath)
Definition: ResourceStorage.php:2036
‪TYPO3\CMS\Core\Resource\ResourceStorage\renameFile
‪FileInterface renameFile($file, $targetFileName, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:1987
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface
Definition: DriverInterface.php:22
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFile
‪FileInterface getFile($identifier)
Definition: ResourceStorage.php:1405
‪TYPO3\CMS\Core\Resource\ResourceStorage\getDriver
‪Driver DriverInterface getDriver()
Definition: ResourceStorage.php:251
‪TYPO3\CMS\Core\Resource\ResourceStorage\$isOnline
‪bool $isOnline
Definition: ResourceStorage.php:144
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFileByIdentifier
‪string hashFileByIdentifier($fileIdentifier, $hash)
Definition: ResourceStorage.php:1281
‪TYPO3\CMS\Core\Resource\ResourceFactory\getInstance
‪static ResourceFactory getInstance()
Definition: ResourceFactory.php:39
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\withFolder
‪withFolder(Folder $folder)
Definition: FileSearchDemand.php:116
‪TYPO3\CMS\Core\Resource\Folder\getParentFolder
‪Folder getParentFolder()
Definition: Folder.php:533
‪TYPO3\CMS\Core\Resource\FileInterface\getSize
‪int getSize()
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
Definition: ExistingTargetFileNameException.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\DEFAULT_ProcessingFolder
‪const DEFAULT_ProcessingFolder
Definition: ResourceStorageInterface.php:71
‪TYPO3\CMS\Core\Resource\ResourceStorage\getObjectManager
‪ObjectManager getObjectManager()
Definition: ResourceStorage.php:2930
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasCapability
‪bool hasCapability($capability)
Definition: ResourceStorage.php:306
‪TYPO3\CMS\Core\Resource\ResourceStorage\getProcessingFolders
‪Folder[] getProcessingFolders()
Definition: ResourceStorage.php:1607
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFileReplaceSignal
‪emitPreFileReplaceSignal(FileInterface $file, $localFilePath)
Definition: ResourceStorage.php:2657
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileIdentifiersInFolder
‪array getFileIdentifiersInFolder($folderIdentifier, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1555
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository\findByFolder
‪array null findByFolder(Folder $folder)
Definition: FileIndexRepository.php:201
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderInfo
‪array getFolderInfo(Folder $folder)
Definition: ResourceStorage.php:2439
‪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:2377
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFolderRenameSignal
‪emitPreFolderRenameSignal(Folder $folder, $newName)
Definition: ResourceStorage.php:2813
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinFileMountBoundaries
‪bool isWithinFileMountBoundaries($subject, $checkWriteAccess=false)
Definition: ResourceStorage.php:536
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileContents
‪string getFileContents($file)
Definition: ResourceStorage.php:1672
‪TYPO3\CMS\Core\Utility\PathUtility\getCanonicalPath
‪static string getCanonicalPath($path)
Definition: PathUtility.php:306
‪TYPO3\CMS\Core\Resource\ResourceStorage\isDefault
‪bool isDefault()
Definition: ResourceStorage.php:3159
‪TYPO3\CMS\Core\Resource\ResourceStorage\isProcessingFolder
‪bool isProcessingFolder(Folder $folder)
Definition: ResourceStorage.php:1639
‪TYPO3\CMS\Core\Utility\PathUtility\pathinfo
‪static string array pathinfo($path, $options=null)
Definition: PathUtility.php:207
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileInFolder
‪File ProcessedFile null getFileInFolder($fileName, Folder $folder)
Definition: ResourceStorage.php:1500
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFile
‪bool hasFile($identifier)
Definition: ResourceStorage.php:1593
‪TYPO3\CMS\Core\Utility\PathUtility\basename
‪static string basename($path)
Definition: PathUtility.php:164
‪TYPO3\CMS\Core\Resource\ResourceStorage\setFileContents
‪int setFileContents(AbstractFile $file, $contents)
Definition: ResourceStorage.php:1785
‪TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException
Definition: InvalidTargetFolderException.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorage\getRootLevelFolder
‪Folder getRootLevelFolder($respectFileMounts=true)
Definition: ResourceStorage.php:2536
‪TYPO3\CMS\Core\Resource\Folder\getName
‪string getName()
Definition: Folder.php:91
‪TYPO3\CMS\Core\Resource\ResourceStorage\$capabilities
‪int $capabilities
Definition: ResourceStorage.php:124
‪TYPO3\CMS\Core\Utility\PathUtility\getRelativePathTo
‪static string null getRelativePathTo($targetPath)
Definition: PathUtility.php:31
‪TYPO3\CMS\Core\Resource\Folder\getStorage
‪ResourceStorage getStorage()
Definition: Folder.php:146
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFileIdentifier
‪string hashFileIdentifier($file)
Definition: ResourceStorage.php:1298
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFile
‪FileInterface addFile($localFilePath, Folder $targetFolder, $targetFileName='', $conflictMode=DuplicationBehavior::RENAME, $removeOriginal=true)
Definition: ResourceStorage.php:1196
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:182
‪TYPO3\CMS\Core\Resource\ResourceStorage\getSignalSlotDispatcher
‪Dispatcher getSignalSlotDispatcher()
Definition: ResourceStorage.php:2917
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileReadPermission
‪assureFileReadPermission(FileInterface $file)
Definition: ResourceStorage.php:851
‪TYPO3\CMS\Core\Resource\ResourceStorage\$driver
‪Driver DriverInterface $driver
Definition: ResourceStorage.php:79
‪TYPO3\CMS\Core\Resource\ResourceStorage\isOnline
‪bool isOnline()
Definition: ResourceStorage.php:395
‪TYPO3\CMS\Core\Resource\InaccessibleFolder
Definition: InaccessibleFolder.php:26
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileAndFolderNameFilters
‪bool checkFileAndFolderNameFilters(ResourceInterface $fileOrFolder)
Definition: ResourceStorage.php:756
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFolderActionPermission
‪bool checkFolderActionPermission($action, Folder $folder=null)
Definition: ResourceStorage.php:707
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\setEvaluatePermissions
‪setEvaluatePermissions($evaluatePermissions)
Definition: ResourceStorage.php:579
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFile
‪FileInterface moveFile($file, $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:1924
‪TYPO3\CMS\Core\Resource\AbstractFile
Definition: AbstractFile.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\getRole
‪string getRole(FolderInterface $folder)
Definition: ResourceStorage.php:2968
‪TYPO3\CMS\Core\Resource\ResourceStorage\markAsPermanentlyOffline
‪markAsPermanentlyOffline()
Definition: ResourceStorage.php:441
‪TYPO3\CMS\Core\Resource\ResourceStorage\getAllFileObjectsInFolder
‪File[] getAllFileObjectsInFolder(Folder $folder)
Definition: ResourceStorage.php:2095
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileMovePermissions
‪assureFileMovePermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
Definition: ResourceStorage.php:1002
‪TYPO3\CMS\Core\Resource\Search\Result\FileSearchResult
Definition: FileSearchResult.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFileRenameSignal
‪emitPreFileRenameSignal(FileInterface $file, $targetFolder)
Definition: ResourceStorage.php:2635
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileAndFolderNameFilters
‪array getFileAndFolderNameFilters()
Definition: ResourceStorage.php:1460
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileAddPermissions
‪assureFileAddPermissions($targetFolder, $targetFileName)
Definition: ResourceStorage.php:945
‪TYPO3\CMS\Core\Resource\ResourceStorage\setFileAndFolderNameFilters
‪$this setFileAndFolderNameFilters(array $filters)
Definition: ResourceStorage.php:1469
‪TYPO3\CMS\Core\Resource\ResourceStorage\getCapabilities
‪int getCapabilities()
Definition: ResourceStorage.php:295
‪TYPO3\CMS\Core\Resource\ResourceStorage\copyFolderBetweenStorages
‪copyFolderBetweenStorages(Folder $folderToCopy, Folder $targetParentFolder, $newFolderName)
Definition: ResourceStorage.php:2228
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFileCopySignal
‪emitPostFileCopySignal(FileInterface $file, Folder $targetFolder)
Definition: ResourceStorage.php:2600
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileForLocalProcessing
‪string getFileForLocalProcessing(FileInterface $fileObject, $writable=true)
Definition: ResourceStorage.php:1393
‪TYPO3\CMS\Core\Resource\ResourceFactory\convertFlexFormDataToConfigurationArray
‪array convertFlexFormDataToConfigurationArray($flexFormData)
Definition: ResourceFactory.php:292
‪TYPO3\CMS\Core\Resource\Folder\getSubfolders
‪Folder[] getSubfolders($start=0, $numberOfItems=0, $filterMode=self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, $recursive=false)
Definition: Folder.php:287
‪TYPO3\CMS\Core\Resource\ResourceStorage\isBrowsable
‪bool isBrowsable()
Definition: ResourceStorage.php:340
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFolder
‪Folder createFolder($folderName, Folder $parentFolder=null)
Definition: ResourceStorage.php:2409
‪TYPO3\CMS\Core\Resource\Folder\createFolder
‪Folder createFolder($folderName)
Definition: Folder.php:361
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFolderMoveSignal
‪emitPreFolderMoveSignal(Folder $folder, Folder $targetFolder, $newName)
Definition: ResourceStorage.php:2789
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand
Definition: FileSearchDemand.php:24
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFileAddSignal
‪emitPostFileAddSignal(FileInterface $file, Folder $targetFolder)
Definition: ResourceStorage.php:2578
‪TYPO3\CMS\Core\Resource\Search\Result\DriverFilteredSearchResult
Definition: DriverFilteredSearchResult.php:27
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:34
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:33
‪TYPO3\CMS\Core\Resource\Index\FileIndexRepository\getInstance
‪static FileIndexRepository getInstance()
Definition: FileIndexRepository.php:70
‪TYPO3\CMS\Core\Resource\ResourceStorage\createFile
‪FileInterface createFile($fileName, Folder $targetFolderObject)
Definition: ResourceStorage.php:1811
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinFolder
‪bool isWithinFolder(Folder $folder, ResourceInterface $resource)
Definition: ResourceStorage.php:2517
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\RENAME
‪const RENAME
Definition: DuplicationBehavior.php:31
‪TYPO3\CMS\Core\Resource\ResourceStorage\autoExtractMetadataEnabled
‪bool autoExtractMetadataEnabled()
Definition: ResourceStorage.php:429
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFileCreateSignal
‪emitPreFileCreateSignal(string $fileName, Folder $targetFolder)
Definition: ResourceStorage.php:2679
‪TYPO3\CMS\Core\Resource\FolderInterface\getSubfolder
‪Folder getSubfolder($name)
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileDeletePermissions
‪assureFileDeletePermissions(FileInterface $file)
Definition: ResourceStorage.php:913
‪TYPO3\CMS\Core\Resource\ResourceStorage\getConfiguration
‪array getConfiguration()
Definition: ResourceStorage.php:209
‪TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: AbstractFile.php:418
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasChildren
‪bool hasChildren()
Definition: ResourceStorage.php:281
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileMounts
‪array getFileMounts()
Definition: ResourceStorage.php:523
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_PROCESSING
‪const ROLE_PROCESSING
Definition: FolderInterface.php:27
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinProcessingFolder
‪bool isWithinProcessingFolder($identifier)
Definition: ResourceStorage.php:2497
‪TYPO3\CMS\Extbase\SignalSlot\Dispatcher\dispatch
‪mixed dispatch($signalClassName, $signalName, array $signalArguments=[])
Definition: Dispatcher.php:115
‪TYPO3\CMS\Core\Resource\ResourceStorage\getBackendUser
‪TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser()
Definition: ResourceStorage.php:3177
‪TYPO3\CMS\Core\Resource\ResourceStorage\moveFolderBetweenStorages
‪moveFolderBetweenStorages(Folder $folderToMove, Folder $targetParentFolder, $newFolderName)
Definition: ResourceStorage.php:2173
‪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:215
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderCopyPermissions
‪assureFolderCopyPermissions(FolderInterface $folderToCopy, FolderInterface $targetParentFolder)
Definition: ResourceStorage.php:1099
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFileObjectFromCombinedIdentifier
‪File ProcessedFile null getFileObjectFromCombinedIdentifier($identifier)
Definition: ResourceFactory.php:424
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_MOUNT
‪const ROLE_MOUNT
Definition: FolderInterface.php:30
‪TYPO3\CMS\Core\Resource\AbstractFile\getParentFolder
‪FolderInterface getParentFolder()
Definition: AbstractFile.php:573
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileProcessingService
‪Service FileProcessingService $fileProcessingService
Definition: ResourceStorage.php:95
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNamesForNestedProcessingFolder
‪string[] getNamesForNestedProcessingFolder($fileIdentifier, $levels)
Definition: ResourceStorage.php:3115
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFileMoveSignal
‪emitPreFileMoveSignal(FileInterface $file, Folder $targetFolder, string $targetFileName)
Definition: ResourceStorage.php:2612
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFileAddSignal
‪string emitPreFileAddSignal($targetFileName, Folder $targetFolder, $sourceFilePath)
Definition: ResourceStorage.php:2566
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFileRenameSignal
‪emitPostFileRenameSignal(FileInterface $file, $sanitizedTargetFileName)
Definition: ResourceStorage.php:2646
‪TYPO3\CMS\Core\Resource\Search\Result\FileSearchResultInterface
Definition: FileSearchResultInterface.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\sanitizeFileName
‪string sanitizeFileName($fileName, Folder $targetFolder=null)
Definition: ResourceStorage.php:1169
‪TYPO3\CMS\Core\Resource\Folder\getSubfolder
‪Folder getSubfolder($name)
Definition: Folder.php:270
‪TYPO3\CMS\Core\Resource\ResourceInterface\getName
‪string getName()
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_USER_MOUNT
‪const ROLE_USER_MOUNT
Definition: FolderInterface.php:32
‪TYPO3\CMS\Core\Resource\ResourceStorage\$isDefault
‪bool $isDefault
Definition: ResourceStorage.php:148
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFolderCopySignal
‪emitPostFolderCopySignal(Folder $folder, Folder $targetFolder, $newName)
Definition: ResourceStorage.php:2777
‪TYPO3\CMS\Core\Resource
Definition: generateMimeTypes.php:37
‪TYPO3\CMS\Core\Resource\ProcessedFile
Definition: ProcessedFile.php:42
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_BROWSABLE
‪const CAPABILITY_BROWSABLE
Definition: ResourceStorageInterface.php:54
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\getInstance
‪static OnlineMediaHelperRegistry getInstance()
Definition: OnlineMediaHelperRegistry.php:31
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFolderMoveSignal
‪emitPostFolderMoveSignal(Folder $folder, Folder $targetFolder, $newName, Folder $originalFolder)
Definition: ResourceStorage.php:2802
‪TYPO3\CMS\Core\Resource\ResourceStorage\$processingFolders
‪Folder[] $processingFolders
Definition: ResourceStorage.php:138
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderReadPermission
‪assureFolderReadPermission(Folder $folder=null)
Definition: ResourceStorage.php:798
‪TYPO3\CMS\Core\Resource\ResourceStorage\usesCaseSensitiveIdentifiers
‪bool usesCaseSensitiveIdentifiers()
Definition: ResourceStorage.php:385
‪TYPO3\CMS\Core\Resource\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Core\Http\FalDumpFileContentsDecoratorStream
Definition: FalDumpFileContentsDecoratorStream.php:32
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFileInFolder
‪bool hasFileInFolder($fileName, Folder $folder)
Definition: ResourceStorage.php:1658
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_READONLY_MOUNT
‪const ROLE_READONLY_MOUNT
Definition: FolderInterface.php:31
‪TYPO3\CMS\Core\Resource\AbstractFile\setIdentifier
‪File setIdentifier($identifier)
Definition: AbstractFile.php:406
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileCopyPermissions
‪assureFileCopyPermissions(FileInterface $file, Folder $targetFolder, $targetFileName)
Definition: ResourceStorage.php:1065
‪TYPO3\CMS\Core\Resource\ResourceFactory\createFolderObject
‪Folder createFolderObject(ResourceStorage $storage, $identifier, $name)
Definition: ResourceFactory.php:383
‪TYPO3\CMS\Core\Resource\ResourceStorage\$evaluatePermissions
‪bool $evaluatePermissions
Definition: ResourceStorage.php:104
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:74
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreGeneratePublicUrlSignal
‪emitPreGeneratePublicUrlSignal(ResourceInterface $resourceObject, $relativeToCurrentScript, array $urlData)
Definition: ResourceStorage.php:2857
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFileCopySignal
‪emitPreFileCopySignal(FileInterface $file, Folder $targetFolder)
Definition: ResourceStorage.php:2589
‪TYPO3\CMS\Core\Resource\ResourceStorage\getPseudoStream
‪ResponseInterface getPseudoStream(FileInterface $file, bool $asDownload=false, string $alternativeFilename=null, string $overrideMimeType=null)
Definition: ResourceStorage.php:1751
‪TYPO3\CMS\Core\Resource\ResourceFactory\getStorageObject
‪ResourceStorage getStorageObject($uid, array $recordData=[], &$fileIdentifier=null)
Definition: ResourceFactory.php:131
‪TYPO3\CMS\Core\Resource\ResourceStorage\searchFiles
‪FileSearchResultInterface searchFiles(FileSearchDemand $searchDemand, Folder $folder=null, bool $useFilters=true)
Definition: ResourceStorage.php:364
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderMovePermissions
‪assureFolderMovePermissions(FolderInterface $folderToMove, FolderInterface $targetParentFolder)
Definition: ResourceStorage.php:1135
‪TYPO3\CMS\Core\Resource\ResourceStorage\isPublic
‪bool isPublic()
Definition: ResourceStorage.php:319
‪TYPO3\CMS\Core\Log\LogManager
Definition: LogManager.php:25
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Extbase\Object\ObjectManager\get
‪object &T get($objectName,... $constructorArguments)
Definition: ObjectManager.php:94
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNearestRecyclerFolder
‪Folder null getNearestRecyclerFolder(FileInterface $file)
Definition: ResourceStorage.php:3193
‪TYPO3\CMS\Core\Resource\ResourceStorage\countFoldersInFolder
‪int countFoldersInFolder(Folder $folder, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:2364
‪TYPO3\CMS\Core\Resource\FolderInterface\ROLE_RECYCLER
‪const ROLE_RECYCLER
Definition: FolderInterface.php:26
‪TYPO3\CMS\Core\Resource\FolderInterface
Definition: FolderInterface.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorage\hashFile
‪string hashFile(FileInterface $fileObject, $hash)
Definition: ResourceStorage.php:1268
‪TYPO3\CMS\Core\Resource\ResourceStorage\$processingFolder
‪Folder $processingFolder
Definition: ResourceStorage.php:132
‪TYPO3\CMS\Core\Resource\ResourceStorage\streamFile
‪ResponseInterface streamFile(FileInterface $file, bool $asDownload=false, string $alternativeFilename=null, string $overrideMimeType=null)
Definition: ResourceStorage.php:1724
‪TYPO3\CMS\Core\Resource\ResourceStorage\setConfiguration
‪setConfiguration(array $configuration)
Definition: ResourceStorage.php:219
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFileObject
‪File getFileObject($uid, array $fileData=[])
Definition: ResourceFactory.php:399
‪TYPO3\CMS\Core\Resource\ResourceStorage\updateProcessedFile
‪FileInterface updateProcessedFile($localFilePath, ProcessedFile $processedFile, Folder $processingFolder=null)
Definition: ResourceStorage.php:1246
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileRenamePermissions
‪assureFileRenamePermissions(FileInterface $file, $targetFileName)
Definition: ResourceStorage.php:1032
‪TYPO3\CMS\Core\Utility\Exception\NotImplementedMethodException
Definition: NotImplementedMethodException.php:25
‪TYPO3\CMS\Core\Resource\Folder\getIdentifier
‪string getIdentifier()
Definition: Folder.php:157
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileWritePermissions
‪assureFileWritePermissions(FileInterface $file)
Definition: ResourceStorage.php:875
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\REPLACE
‪const REPLACE
Definition: DuplicationBehavior.php:38
‪TYPO3\CMS\Core\Resource\ResourceInterface
Definition: ResourceInterface.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFolderRenameSignal
‪emitPostFolderRenameSignal(Folder $folder, $newName, Folder $newFolder)
Definition: ResourceStorage.php:2825
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWritable
‪bool isWritable()
Definition: ResourceStorage.php:330
‪TYPO3\CMS\Core\Resource\Folder\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: Folder.php:178
‪TYPO3\CMS\Core\Resource\ResourceStorage\$userPermissions
‪array $userPermissions
Definition: ResourceStorage.php:117
‪TYPO3\CMS\Core\Resource\Service\FileProcessingService
Definition: FileProcessingService.php:27
‪TYPO3\CMS\Core\Resource\AbstractFile\updateProperties
‪updateProperties(array $properties)
‪TYPO3\CMS\Core\Resource\ResourceStorage\getResourceFactoryInstance
‪ResourceFactory getResourceFactoryInstance()
Definition: ResourceStorage.php:3167
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Resource\ResourceStorage\unsetFileAndFolderNameFilters
‪unsetFileAndFolderNameFilters()
Definition: ResourceStorage.php:1442
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFileDeleteSignal
‪emitPreFileDeleteSignal(FileInterface $file)
Definition: ResourceStorage.php:2700
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkFileActionPermission
‪bool checkFileActionPermission($action, FileInterface $file)
Definition: ResourceStorage.php:640
‪TYPO3\CMS\Core\Resource\FileInterface\getMimeType
‪string getMimeType()
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:42
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFolderIdentifiersInFolder
‪array getFolderIdentifiersInFolder($folderIdentifier, $useFilters=true, $recursive=false)
Definition: ResourceStorage.php:1581
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFileMoveSignal
‪emitPostFileMoveSignal(FileInterface $file, Folder $targetFolder, FolderInterface $originalFolder)
Definition: ResourceStorage.php:2624
‪TYPO3\CMS\Core\Resource\ResourceStorage\checkUserActionPermission
‪bool checkUserActionPermission($action, $type)
Definition: ResourceStorage.php:613
‪TYPO3\CMS\Core\Resource\ResourceInterface\getParentFolder
‪FolderInterface getParentFolder()
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFolderDeleteSignal
‪emitPostFolderDeleteSignal(Folder $folder)
Definition: ResourceStorage.php:2845
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPostFileSetContentsSignal
‪emitPostFileSetContentsSignal(FileInterface $file, $content)
Definition: ResourceStorage.php:2732
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:25
‪TYPO3\CMS\Core\Resource\Driver\StreamableDriverInterface
Definition: StreamableDriverInterface.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUniqueName
‪string getUniqueName(FolderInterface $folder, $theFile, $dontCheckForUnique=false)
Definition: ResourceStorage.php:2877
‪TYPO3\CMS\Core\Resource\ResourceStorage\deleteFile
‪bool deleteFile($fileObject)
Definition: ResourceStorage.php:1828
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFolderDeletePermission
‪assureFolderDeletePermission(Folder $folder, $checkDeleteRecursively)
Definition: ResourceStorage.php:823
‪TYPO3\CMS\Core\Resource\Exception\InvalidHashException
Definition: InvalidHashException.php:23
‪TYPO3\CMS\Core\Resource\ResourceStorage\getIndexer
‪Index Indexer getIndexer()
Definition: ResourceStorage.php:3143
‪TYPO3\CMS\Core\Resource\Folder\hasFolder
‪bool hasFolder($name)
Definition: Folder.php:409
‪TYPO3\CMS\Core\Resource\ResourceStorage\hasFolderInFolder
‪bool hasFolderInFolder($folderName, Folder $folder)
Definition: ResourceStorage.php:2390
‪TYPO3\CMS\Core\Resource\ResourceStorage\getFileIndexRepository
‪Index FileIndexRepository getFileIndexRepository()
Definition: ResourceStorage.php:2946
‪TYPO3\CMS\Core\Resource\ResourceStorage\copyFolder
‪Folder copyFolder(FolderInterface $folderToCopy, FolderInterface $targetParentFolder, $newFolderName=null, $conflictMode=DuplicationBehavior::RENAME)
Definition: ResourceStorage.php:2188
‪TYPO3\CMS\Core\Resource\ProcessedFile\getName
‪string getName()
Definition: ProcessedFile.php:321
‪TYPO3\CMS\Core\Resource\ResourceStorageInterface\CAPABILITY_WRITABLE
‪const CAPABILITY_WRITABLE
Definition: ResourceStorageInterface.php:63
‪TYPO3\CMS\Core\Resource\ResourceStorage\setDefault
‪setDefault($isDefault)
Definition: ResourceStorage.php:3151
‪TYPO3\CMS\Core\Resource\ResourceStorage\getName
‪string getName()
Definition: ResourceStorage.php:261
‪TYPO3\CMS\Core\Resource\ResourceStorage\$fileMounts
‪array $fileMounts
Definition: ResourceStorage.php:110
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFileObjectByStorageAndIdentifier
‪File ProcessedFile null getFileObjectByStorageAndIdentifier($storageUid, &$fileIdentifier)
Definition: ResourceFactory.php:454
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFileSetContentsSignal
‪emitPreFileSetContentsSignal(FileInterface $file, $content)
Definition: ResourceStorage.php:2721
‪TYPO3\CMS\Extbase\SignalSlot\Dispatcher
Definition: Dispatcher.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage\emitPreFolderAddSignal
‪emitPreFolderAddSignal(Folder $targetFolder, $name)
Definition: ResourceStorage.php:2743
‪TYPO3\CMS\Core\Resource\ResourceStorage\assureFileUploadPermissions
‪assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileSize)
Definition: ResourceStorage.php:976
‪TYPO3\CMS\Core\Resource\AbstractFile\getStorage
‪ResourceStorage getStorage()
Definition: AbstractFile.php:361
‪TYPO3\CMS\Core\Resource\ResourceStorage\getNestedProcessingFolder
‪Folder getNestedProcessingFolder(File $file, Folder $rootProcessingFolder)
Definition: ResourceStorage.php:3083