Class: AWS::S3::BucketCollection
- Inherits:
-
Object
- Object
- AWS::S3::BucketCollection
- Defined in:
- lib/httpimagestore/aws_sdk_regions_hack.rb
Instance Method Summary collapse
Instance Method Details
#[](name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/httpimagestore/aws_sdk_regions_hack.rb', line 5 def [](name) # if name is DNS compatible we still cannot use it for writes if it does contain dots return S3::Bucket.new(name.to_s, :owner => nil, :config => config) if client.dns_compatible_bucket_name?(name) and not name.include? '.' # save region mapping for bucket for futher requests @@location_cache = {} unless defined? @@location_cache # if we have it cased use it; else try to fetch it and if it is nil bucket is in standard region region = @@location_cache[name] || @@location_cache[name] = S3::Bucket.new(name.to_s, :owner => nil, :config => config).location_constraint || @@location_cache[name] = :standard # no need to specify region if bucket is in standard region return S3::Bucket.new(name.to_s, :owner => nil, :config => config) if region == :standard # use same config but with region specified for buckets that are not DNS compatible or have dots and are not in standard region S3::Bucket.new(name.to_s, :owner => nil, :config => config.with(region: region)) end |