Sha256: 7d757e98a8de1a5a190dc186ef8e9517fa33d32943fa85878cb05ca582130541

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

# for setting up test bucket, so can gather responses from the real S3
require 'yaml'
require File.dirname(__FILE__) + '/../lib/s33r.rb'

config_file = '/home/ell/.s33r'

options = YAML::load_file(config_file)
access_key = options['access_key']
secret_key = options['secret_key']

bucket = 'elliotsmith-testing'

def bucketeer(client, bucket)
  lambda do |key, text|
    client.put_text bucket, '/home/ell/' + key, text
  end
end

S3::Client.new(access_key, secret_key) do |client|

  if !client.bucket_exists?(bucket)
    client.create_bucket(bucket)

    b = bucketeer(client, bucket)
    b.call 'one.txt', 'one text file'
    b.call 'two.txt', 'two text file'
    b.call 'dir1/three.txt', 'three text file'
    b.call 'dir1/four.txt', 'four text file'
    b.call 'dir2/five.txt', 'five text file'
    b.call 'dir2/six.txt', 'six text file'
    b.call 'dir2/subdir21/seven.txt', 'seven text file'
    b.call 'dir2/subdir22/eight.txt', 'eight text file'
    b.call 'dir2/subdir22/subdir221/nine.txt', 'nine text file'
    b.call 'dir2/subdir22/subdir221/ten.txt', 'ten text file'

  end

#  p client.list_bucket(bucket, :prefix => '/home/ell/dir1').body
#  p client.list_bucket(bucket, :marker => '/home/ell/dir2/six.txt').body
   p client.list_bucket(bucket).body
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
s33r-0.4.2 test/test_bucket_setup.rb
s33r-0.2 test/test_bucket_setup.rb
s33r-0.3.1 test/test_bucket_setup.rb
s33r-0.4 test/test_bucket_setup.rb
s33r-0.3 test/test_bucket_setup.rb
s33r-0.4.1 test/test_bucket_setup.rb