Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder identifiers sometimes have / at the end, sometimes not #146

Open
cweiske opened this issue Jan 22, 2024 · 1 comment · May be fixed by #147
Open

Folder identifiers sometimes have / at the end, sometimes not #146

cweiske opened this issue Jan 22, 2024 · 1 comment · May be fixed by #147

Comments

@cweiske
Copy link
Contributor

cweiske commented Jan 22, 2024

Different methods in AmazonS3Driver return folder identifiers differently:

  • AmazonS3Driver::createFolder returns identifiers with a slash at the end: folder/
  • AmazonS3Driver::getFolder returns identifiers without a slash: foldername.
  • AmazonS3Driver::getFolderInfoByIdentifier returns identifiers without a slash: foldername.

This leads to the problem that creating a new file via addFile($localFilePath, $targetFolderIdentifier, $newFileName) will not put the file within the folder, but in the parent folder:

addFile('/tmp/foo', 'folder', 'filename.txt') creates /folderfilename.txt instead of folder/filename.txt.

Some methods already handle folder identifiers without slash and with slashes:

  • fileExistsInFolder
  • folderExistsInFolder
  • getFolderInFolder
  • getFileInFolder
  • createFile
  • createFolder

Other methods do not add slashes:

  • addFile
  • moveFileWithinStorage
  • copyFileWithinStorage
  • moveFolderWithinStorage
  • copyFolderWithinStorage

The question is now if folder identifiers should always have a slash at the end or not.
The decision to that question determines what needs to be done to solve the bugs.

@cweiske
Copy link
Contributor Author

cweiske commented Jan 22, 2024

AbstractHierarchicalFilesystemDriver::canonicalizeAndCheckFolderIdentifier appends a slash when missing, so I guess that folders should always have a slash at the end.

cweiske added a commit to mogic-le/aus_driver_amazon_s3 that referenced this issue Jan 23, 2024
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: andersundsehr#146
@cweiske cweiske linked a pull request Jan 23, 2024 that will close this issue
cweiske added a commit to mogic-le/aus_driver_amazon_s3 that referenced this issue Jan 23, 2024
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: andersundsehr#146
cweiske added a commit to mogic-le/aus_driver_amazon_s3 that referenced this issue Jun 17, 2024
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: andersundsehr#146
cweiske added a commit to mogic-le/aus_driver_amazon_s3 that referenced this issue Sep 6, 2024
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: andersundsehr#146
cweiske added a commit to mogic-le/aus_driver_amazon_s3 that referenced this issue Sep 6, 2024
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: andersundsehr#146
cweiske added a commit to mogic-le/aus_driver_amazon_s3 that referenced this issue Dec 13, 2024
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: andersundsehr#146
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants