从S3递归使用博托蟒蛇下载的文件。 [英] Downloading the files from s3 recursively using boto python.
本文介绍了从S3递归使用博托蟒蛇下载的文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个水桶在S3中,其中有着很深的目录结构。我希望我能立刻下载它们。我的文件是这样的:
I have a bucket in s3, which has deep directory structure. I wish I could download them all at once. My files look like this :
foo/bar/1. .
foo/bar/100 . .
有没有什么方法可以使用Python中博托lib中的S3存储递归地下载这些文件?
Are there any ways to download these files recursively from the s3 bucket using boto lib in python?
在此先感谢。
推荐答案
您可以下载在这样一个桶中的所有文件(未测试):
You can download all files in a bucket like this (untested):
from boto.s3.connection import S3Connection
conn = S3Connection('your-access-key','your-secret-key')
bucket = conn.get_bucket('bucket')
for key in bucket.list():
try:
res = key.get_contents_to_filename(key.name)
except:
logging.info(key.name+":"+"FAILED")
记
请在S3文件夹写入键值名,只有客户端将显示这是文件夹只是另一种方式。
Keep in mind that folders in S3 are simply another way of writing the key name and only clients will show this as folders.
这篇关于从S3递归使用博托蟒蛇下载的文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文