我正在尝试从给定存储桶中获取特定文件:
my_bucket
dirA
dirX
file1.json
file2.json
file1.csv
dirY
file2.csv
dirZ
dirX
file3.json
file3.csv
使用python的sdk“match_glob”参数,我想仅获取符合
**/dirX/**.json
模式的文件。
即:我想得到
dirA/dirX/file1.json
、dirA/dirX/file2.json
和 dirZ/dirX/file3.json
文件。
尝试
**/dirX/**.json
模式产生空结果。
这个模式有什么问题吗?
提前致谢!
您可以尝试使用此模式
**/*.json
而不是 **/dirX/**.json
,因为它会返回空结果,因为dirX不是存储桶根目录上的目录,而是dirA和dirZ的子目录。
您可以像
**/*.json
一样使用match_glob参数,此模式将获取存储桶中任何目录的dirX子目录中的所有.json文件。
当 matchGlob 查询参数设置为 glob 模式时,对象列表操作仅返回与 items[] 中的 glob 模式匹配的对象。您可以检查此使用 glob 列出对象和前缀