def write_s3_data():
"""Takes the default data from FakeBucket and writes it to S3.
Allows running the same tests against fakes and the boto api.
"""
cfg = get_config()
bucket = boto.connect_s3(
cfg['S3_KEY_ID'], cfg['S3_SECRET']).get_bucket(cfg['BUCKET'])
for name, metadata in FakeBucket.fake_data.iteritems():
key = bucket.new_key(os.path.join(FakeBucket.rand_prefix, name))
headers = {("x-amz-meta-" + k): v for k, v in metadata.iteritems()}
key.set_contents_from_string("spam", headers=headers)
return bucket
评论列表
文章目录