Ruby的AWS-SDK:"找不到标记在S3对象列表响应" [英] Ruby aws-sdk: "Unable to find marker in S3 list objects response"

查看:181
本文介绍了Ruby的AWS-SDK:"找不到标记在S3对象列表响应"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想遍历一个AWS :: S3 ::树对象的孩子,像这样:

I am trying to iterate over the children of a AWS::S3::Tree object, like so:

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)

这工作正常最让我为preFIX使用的路径,但一个文件夹(也有数以万计的子文件夹中)返回此错误:

This works fine on most of the paths I use as a prefix, but one folder (that has tens of thousands of sub folders) returns this error:

/lib/aws/s3/object_collection.rb:311:in `next_markers': Unable to find marker in S3 list objects response (RuntimeError)

我已经覆盖了宝石的方法来调试像这样:

I have overridden the gem method to debug like so:

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

和这个输出返回的数据:

And this outputs the returned data:

{:delimiter=>"/", :contents=>[], :common_prefixes=>[{:prefix=>"assets/images/100/"}, {:prefix=>"assets/images/1000/"}, {:prefix=>"assets/images/1001/"}, etc etc

为什么调用返回一个空数组:内容

Why is the call returning an empty array for :contents ?

推荐答案

这种情况发生时从S3的XML是无效的,内容不能被解析。如果启用wiretracing(地址:http_wire_trace => true以AWS :: S3.new),你应该能够检查有问题的HTTP响应主体

This happens when the XML from S3 is not valid and the contents can not be parsed. If you enable wiretracing (add :http_wire_trace => true to AWS::S3.new) and you should be able to examine the offending http response body.

这篇关于Ruby的AWS-SDK:"找不到标记在S3对象列表响应"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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