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

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

问题描述

我有一个亚马逊 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?

推荐答案

我建议使用 boto.然后是一个快速的几行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

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

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