Skip to content

Support REST Bucket Get v2 #369

@khoan

Description

@khoan

Parser doesn't support ContinuationToken as per http://docs.aws.amazon.com/AmazonS3/latest/API/v2-RESTBucketGET.html

require 'fog/aws'

Fog::Storage.new(
  :provider => 'AWS',
  :aws_access_key_id => ':key',
  :aws_secret_access_key => ':secret'
).tap do |s|
  r = s.get_bucket(':bucket', 'list-type' => 2)

  if r.body['IsTruncated']
    puts r.body['ContinuationToken'].inspect # => nil
  end
end

returns expected result after monkey patch

require 'fog/aws/parsers/storage/get_bucket'
Fog::Parsers::Storage::AWS::GetBucket.class_eval do
  alias_method :original_end_element, :end_element

  def end_element name
    case name
    when 'NextContinuationToken'
      @response['NextContinuationToken'] = value
    else
      original_end_element name
    end
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions