wkwkwk
wkwkwk

Reputation: 320

How to get a list of object with naming pattern in S3?

For example I have all this file in my bucket:

1. FILE137170-001.txt
2. FILE137170-002.txt
3. FILE137170-003.txt
4. FILE123567-001.txt
5. FILE123567-002.txt

If I want object that contain "137170" in the filename, how do I obtain the list of object more efficiently?

Right now, I'm using boto3.client('s3') list_objects function to get all the file then filter their key and use get_object to obtain the list of file that I wanted.

Is there any efficient way, that allow me to just get the file that I need directly based on naming pattern?

Upvotes: 0

Views: 421

Answers (1)

jellycsc
jellycsc

Reputation: 12259

No, there is no efficient way to do it if your objects are named this way. It's only possible if your object names share the common prefix.

Upvotes: 1

Related Questions