Sha256: 1cf2a5167b9e6c897f00b3e9e25f672ebc36ff692eb8a80180a33c80b5c3a688
Contents?: true
Size: 1.86 KB
Versions: 25
Compression:
Stored size: 1.86 KB
Contents
unless Fog.mocking? module Fog module AWS class S3 # Create an S3 bucket # # ==== Parameters # * bucket_name<~String> - name of bucket to create # * options<~Hash> - config arguments for bucket. Defaults to {}. # * :location_constraint<~Symbol> - sets the location for the bucket # # ==== Returns # * response<~Excon::Response>: # * status<~Integer> - 200 def put_bucket(bucket_name, options = {}) if options['LocationConstraint'] data = <<-DATA <CreateBucketConfiguration> <LocationConstraint>#{options['LocationConstraint']}</LocationConstraint> </CreateBucketConfiguration> DATA else data = nil end request({ :expects => 200, :body => data, :headers => {}, :idempotent => true, :host => "#{bucket_name}.#{@host}", :method => 'PUT' }) end end end end else module Fog module AWS class S3 def put_bucket(bucket_name, options = {}) response = Excon::Response.new response.status = 200 bucket = { :objects => {}, 'Name' => bucket_name, 'CreationDate' => Time.now, 'Owner' => { 'DisplayName' => 'owner', 'ID' => 'some_id'}, 'Payer' => 'BucketOwner' } if options['LocationConstraint'] bucket['LocationConstraint'] = options['LocationConstraint'] else bucket['LocationConstraint'] = '' end unless Fog::AWS::S3.data[:buckets][bucket_name] Fog::AWS::S3.data[:buckets][bucket_name] = bucket end response end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems