How to list_objects in aiobotocore not recursively

Viewed 243

I have the following code for getting a list of objects.

paginator = self.client.get_paginator('list_objects')
async for result in paginator.paginate(Bucket=bucket_name, Prefix=prefix):
      for file in result.get('Contents', []):
          yield file

What do I need to add to display objects in only one directory, without recursion?

1 Answers

Add Delimiter='/' kwarg

async for result in paginator.paginate(Bucket=bucket_name, Prefix=prefix, Delimiter='/'):
        for file in result.get('Contents', []):
            yield file
Related