Module: Bukelatta::Ext::AwsS3BucketExt

Defined in:
lib/bukelatta/ext/aws_s3_bucket_ext.rb

Constant Summary collapse

DEFULT_CONCURRENCY =
8

Instance Method Summary collapse

Instance Method Details

#auto_redirectObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bukelatta/ext/aws_s3_bucket_ext.rb', line 5

def auto_redirect
  ret = nil
  bckt = self

  begin
    ret = yield(bckt)
  rescue Aws::S3::Errors::PermanentRedirect => e
    res_body = MultiXml.parse(e.context.http_response.body.read)
    edpnt = res_body['Error']['Endpoint']
    clnt = Aws::S3::Client.new(endpoint: "https://#{edpnt}")
    rsrc = Aws::S3::Resource.new(client: clnt)
    bckt = rsrc.bucket(bckt.name)
    retry
  end

  ret
end