我正在尝试遍历 AWS::S3::Tree 对象的子对象,如下所示:
conn = AWS::S3.new(:access_key_id => 'ACCESSKEYID', :secret_access_key => 'ACCESSKEY')
bucket = conn.buckets['bucketname']
tree = bucket.objects.with_prefix('assets/images').as_tree
directories = tree.children.select(&:branch?).collect(&:prefix)
这在我用作前缀的大多数路径上都可以正常工作,但是一个文件夹(具有数万个子文件夹)会返回此错误:
/lib/aws/s3/object_collection.rb:311:in `next_markers': Unable to find marker in S3 list objects response (RuntimeError)
我已经重写了 gem 方法来调试,如下所示:
module AWS
class S3
class ObjectCollection
protected
def next_markers page
raise page.inspect
marker = (last = page.contents.last and last.key)
if marker.nil?
raise 'Unable to find marker in S3 list objects response xxxxx'
else
{ :marker => marker }
end
end
end
end
end
这将输出返回的数据:
{:delimiter=>"/", :contents=>[], :common_prefixes=>[{:prefix=>"assets/images/100/"}, {:prefix=>"assets/images/1000/"}, {:prefix=>"assets/images/1001/"}, etc etc
为什么调用为 :contents 返回一个空数组?