How to list all files in Google Storage bucket in a short time?

那年仲夏 提交于 2020-02-24 05:20:35

问题


I have a Google Storage bucket that contains more than 20k+ filenames. Is there any way to list all the filenames in the bucket in a short time?


回答1:


It depends on what you mean by "short", but:

One thing you can do to speed up listing a bucket is to shard the listing operation. For example, if your bucket has objects that begin with English alphabetic characters you could list each letter in parallel and combine the results. You could do this with gsutil in bash like this:

gsutil ls gs://your-bucket/a* > a.out &
gsutil ls gs://your-bucket/b* > b.out &
...
gsutil ls gs://your-bucket/b* > z.out &
wait
cat ?.out > listing.out

If your bucket has objects with different naming you'd have to adjust how you do the sharding.



来源:https://stackoverflow.com/questions/31492872/how-to-list-all-files-in-google-storage-bucket-in-a-short-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!