From dc1a79b68fa3a9b45f002aeadc831318d70331d6 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 23 Jan 2024 16:10:42 +0100 Subject: [PATCH] [BUGFIX] Append slash to folder identifiers This patch fixes the problem that fetching a folder via API and using that to upload a file put the file into the wrong folder: $folder = $storage->getFolder('myfolder'); $storage->addFile('/tmp/file.txt', $folder, 'file.txt'); //created "/myfolderfile.txt" instead of "/myfolder/file.txt" TYPO3's own `AbstractHierarchicalFilesystemDriver::canonicalizeAndCheckFolderIdentifier` appends slashes, and our `createFolder()` already returned identifiers with slashes at the end. Resolves: https://github.com/andersundsehr/aus_driver_amazon_s3/issues/146 --- Classes/Driver/AmazonS3Driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Driver/AmazonS3Driver.php b/Classes/Driver/AmazonS3Driver.php index 0ca1d38..e497b36 100644 --- a/Classes/Driver/AmazonS3Driver.php +++ b/Classes/Driver/AmazonS3Driver.php @@ -796,7 +796,7 @@ public function getFolderInfoByIdentifier($folderIdentifier) $this->normalizeIdentifier($folderIdentifier); return [ - 'identifier' => $folderIdentifier, + 'identifier' => rtrim($folderIdentifier, '/') . '/', 'name' => basename(rtrim($folderIdentifier, '/')), 'storage' => $this->storageUid, 'mtime' => null, @@ -1451,7 +1451,7 @@ protected function getFolder($identifier) return $this->getRootLevelFolder(); } $this->normalizeIdentifier($identifier); - return new Folder($this->getStorage(), $identifier, basename(rtrim($identifier, '/'))); + return new Folder($this->getStorage(), rtrim($identifier, '/') . '/', basename(rtrim($identifier, '/'))); } /**