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

S3 file listing is not working if the prefix resolves to slash #900

Closed
klopfdreh opened this issue Sep 28, 2023 · 0 comments · Fixed by #912
Closed

S3 file listing is not working if the prefix resolves to slash #900

klopfdreh opened this issue Sep 28, 2023 · 0 comments · Fixed by #912

Comments

@klopfdreh
Copy link
Contributor

Type: Bug

Component:
S3

Describe the bug
If the prefix resolves to / the ListObjectsV2Request is not listing any files

Sample
Just put a txt file into an s3 bucket and use s3://mybucket/*.txt - the prefix resolves to / and the file is not listed

Solution
Use && !optionalPrefix.get().equals("/") to not set the prefix if it is only /

        ListObjectsV2Request.Builder listObjectsV2RequestBuilder = ListObjectsV2Request.builder().bucket(s3BucketName);
        if (optionalPrefix.isPresent() && !optionalPrefix.get().equals("/")) {
            listObjectsV2RequestBuilder = listObjectsV2RequestBuilder.prefix(optionalPrefix.get());
        }
        return listObjectsV2RequestBuilder;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant