Home > Back-end >  How can I only list files from S3 using a wildcard pattern path?
How can I only list files from S3 using a wildcard pattern path?

Time:10-22

I would like to know if it is possible in Java to use wildcard to list all existing files according to a pattern path
For example, if i use this pattern path

s3://dataai/alarms/Json/mydata/[0-9]*/[0-9]*/[0-9]*/*_01.json

it should return all these files for example:

s3://dataai/alarms/Json/mydata/9901/2021/10/1243332_01.json
s3://dataai/alarms/Json/mydata/9912/2021/10/1245432_01.json
s3://dataai/alarms/Json/mydata/9912/2021/09/7665432_01.json
...

Any idea?

CodePudding user response:

Amazon S3 does not support such wildcards when listing objects.

Your code would need to return all objects with that Prefix. Your code should then perform the wildcard check against the list of returned Keys.

  • Related