快速的方法来列出亚马逊S3存储桶中的所有文件? [英] Quick way to list all files in Amazon S3 bucket?

查看:142
本文介绍了快速的方法来列出亚马逊S3存储桶中的所有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Amazon S3的桶,有文件名数以万计的在里面。什么是获得列出所有的文件名中的水桶一个文本文件,最简单的方法?

I have an amazon s3 bucket that has tens of thousands of filenames in it. What's the easiest way to get a text file that lists all the filenames in the bucket?

推荐答案

我推荐使用博托 。然后,它是一个快速一些Python 的行:

I'd recommend using boto. Then it's a quick couple of lines of python:

from boto.s3.connection import S3Connection

conn = S3Connection('access-key','secret-access-key')
bucket = conn.get_bucket('bucket')
for key in bucket.list():
    print key.name.encode('utf-8')

另存为list.py,打开一个终端,然后运行:

Save this as list.py, open a terminal, and then run:

$ python list.py > results.txt

这篇关于快速的方法来列出亚马逊S3存储桶中的所有文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆