我想从此路径All Buckets /abc/or/uploads
我尝试使用此代码段,但只设法获取All Buckets /abc
更改bucket_list = bucket.list('or/uploads')
中的路径
这条线不起作用?为什么呢?
import boto
import sys, os
import logging
bucket_name = 'abc'
conn = boto.connect_s3('XXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXXXX+XXXXXXXXXXXXXX')
bucket = conn.get_bucket(bucket_name)
bucket_list = bucket.list('or/uploads')
for key in bucket.list():
try:
res = key.get_contents_to_filename(key.name)
print "done"
except:
logging.info(key.name + ":" + "FAILED")
答案 0 :(得分:0)
Amazon S3没有文件夹/目录。它是一个平面文件结构。 为了保持目录的外观,路径名称存储为对象Key(filename)的一部分。
确保下载文件的位置具有完全相同的结构,即/abc/or/uploads
摘录
for key in bucket.list('or/uploads'):
try:
res = key.get_contents_to_filename(key.name)
print "done"
except:
logging.info(key.name + ":" + "FAILED")