Skip to content

Commit

Permalink
[BUGFIX] Append slash to folder identifiers
Browse files Browse the repository at this point in the history
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: #146
  • Loading branch information
cweiske committed Jan 23, 2024
1 parent 5dcf086 commit a4e5c77
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Classes/Driver/AmazonS3Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ public function getFolderInfoByIdentifier($folderIdentifier)
$this->normalizeIdentifier($folderIdentifier);

return [
'identifier' => $folderIdentifier,
'identifier' => rtrim($folderIdentifier, '/') . '/',
'name' => basename(rtrim($folderIdentifier, '/')),
'storage' => $this->storageUid,
'mtime' => null,
Expand Down Expand Up @@ -1381,7 +1381,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, '/')));
}

/**
Expand Down

0 comments on commit a4e5c77

Please sign in to comment.