获得参数的错误无效类型,值:['db/',' db1/'],类型:< class' list'> ,,类型:< class' str'>在S3存储桶中读取文件夹时

发布于 2025-02-05 19:07:33 字数 557 浏览 1 评论 0原文

我需要在我的S3桶('db','db1','db2')中列出某些特定文件夹的子文件夹。 我正在设置一个带有感兴趣的文件夹的数组,而不是全部在存储桶中。 我正在使用此“过滤器前缀”方法,但不接受数组。

import boto
s3 = boto3.resource('s3')
my_bucket = s3.Bucket('database_buckets')
for object_summary in my_bucket.objects.filter(Prefix=["db/", "db1/", "db2/"]):
    print(object_summary.key)

错误:botocore.exceptions.paramvalidationerror:参数验证失败: 参数前缀的无效类型,值:['db/','db1/','db2/'],类型:< class'list'>,有效的类型:< class'str'str'str'>

我有什么想法在这些特定文件夹中列出这些文件? 由于有许多文件夹(超过30个文件夹),因此与数组进行操作是理想的选择。

I need to list subfolders of some specific folders in my S3 Bucket ('db', 'db1', 'db2')
I'm setting an array with the folders of interest, and not all of them inside the bucket.
I'm using this 'filter Prefix' method, but it doesn't accept array.

import boto
s3 = boto3.resource('s3')
my_bucket = s3.Bucket('database_buckets')
for object_summary in my_bucket.objects.filter(Prefix=["db/", "db1/", "db2/"]):
    print(object_summary.key)

Error: botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter Prefix, value: ['db/', 'db1/', 'db2/'], type: <class 'list'>, valid types: <class 'str'>

Any ideas for me to list these files inside these specific folders?
As there are many folders (more than 30), it would be ideal to do with array.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文