MatTaNg
MatTaNg

Reputation: 895

Listing Objects with multiple prefixes

My structure on AWS S3 is something like so:

photos
  -->  PA
  -->  NJ
  -->  NY
  --> etc...

As you can see it is a flat folder structure which lists each state.

My question is I would like to list all the objects in each folder based on some set of parameters. So in some cases I may want to load all objects in the PA and NY folder. In some other cases I may want to load all objects in the PA NJ folder.

I am aware that the prefix parameter in the listObjectsV2 function allows you to specify only one path. Is there a way to specify multiple paths(or prefixes) without making multiple separate calls?

Any help is appreciated.

Thank you.

Upvotes: 2

Views: 4439

Answers (1)

Jens Roland
Jens Roland

Reputation: 27770

Make multiple calls. You might be able to use a filter property in a single query, but even if you could, that would force S3 to iterate over every file in /photos/ to compare against your filter, which would be both slow and resource intensive.

Upvotes: 4

Related Questions