如何在 aiobotocore 中不递归地 list_objects

How to list_objects in aiobotocore not recursively

我有以下用于获取对象列表的代码。

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

不递归只在一个目录下显示对象需要添加什么?

添加Delimiter='/' kwarg

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