Sha256: 691121fa4353a52a622034dc701d5b468f97b54b6c4f9dca95c00994b466df4e

Contents?: true

Size: 894 Bytes

Versions: 2

Compression:

Stored size: 894 Bytes

Contents

require 'nokogiri'
module Fog
  module Aliyun
    class Storage
      class Real

        # Get location constraint for an OSS bucket
        #
        # @param bucket_name [String] name of bucket to get location constraint for
        #
        # @see https://help.aliyun.com/document_detail/31967.html
        #
        # note: The OSS Ruby sdk does not support get_bucket_location and there needs to parse response

        def get_bucket_location(bucket_name)
          data = @oss_http.get({:bucket => bucket_name, :sub_res => { 'location' => nil} }, {})
          doc = parse_xml(data.body)
          doc.at_css("LocationConstraint").text
        end

        private

        def parse_xml(content)
          doc = Nokogiri::XML(content) do |config|
            config.options |= Nokogiri::XML::ParseOptions::NOBLANKS
          end

          doc
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-aliyun-0.4.0 lib/fog/aliyun/requests/storage/get_bucket_location.rb
fog-aliyun-0.3.19 lib/fog/aliyun/requests/storage/get_bucket_location.rb