Beispiel #1
0
mp = b.initiate_multipart_upload('multipart_key')

md5 = hashlib.md5()

for i in xrange(0, 4):
    buf = str(i) * 5 * 1024 * 1024

    fp = open(fpath + str(i), 'w+')
    fp.write(buf)
    fp.seek(0, 0)
    fps.append(fp)

    md5.update(buf)

for i in xrange(0, 4):
    mp.upload_part_from_file(fps[i], part_num=i + 1)

mp.complete_upload()

for i in xrange(0, 4):
    os.remove(fpath + str(i))

sum = md5.hexdigest()

k = b.get_key('multipart_key')
buf = k.get_contents_as_string()

test_util.assert_eq(sum, hashlib.md5(buf).hexdigest(), 'test multipart')

test_util.clean_bucket(conn, 'test_multipart_bucket')
Beispiel #2
0
if res1 == True and res2 == False:
    test_util.assert_true( True, 'test exists')

#test get_contents_to_file
with open('file_r1', 'w+') as fp:
    k2.get_contents_to_file(fp)

cont = read_file('file_r1')
test_util.assert_eq( cont, '2'*1024,  'test get_contents_to_file')
os.remove('file_r1')

k2.get_contents_to_filename('file_r2')
cont = read_file('file_r2')
test_util.assert_eq( cont, '2'*1024,  'test get_contents_to_filename')
os.remove('file_r2')

#test generate_url
url =  k2.generate_url(300)
ip, port, sub_url = test_util.get_ip_port_suburl(url)
response = test_util.request(ip, port, sub_url)
test_util.assert_eq( 200, response.status, 'test generate_url' )

#test encrypt_key
k = Key(b, 'encrypt_key')
k.set_contents_from_string('3'*1024, encrypt_key=True)
cont =  k.get_contents_as_string()
test_util.assert_eq( cont, '3'*1024,  'test encrypt_key')

test_util.clean_bucket(conn, 'test_bucket_0')
test_util.clean_bucket(conn, 'test_bucket_2')
md5 = hashlib.md5()

for i in xrange(0, 4):
    buf = str(i)*5*1024*1024

    fp = open(fpath + str(i), 'w+' )
    fp.write(buf)
    fp.seek(0, 0)
    fps.append(fp)

    md5.update(buf)

for i in xrange(0, 4):
    mp.upload_part_from_file(fps[i], part_num=i + 1)

mp.complete_upload()

for i in xrange(0, 4):
    os.remove(fpath + str(i))

sum = md5.hexdigest()

k = b.get_key('multipart_key')
buf = k.get_contents_as_string()

test_util.assert_eq( sum, hashlib.md5(buf).hexdigest(),  'test multipart')

test_util.clean_bucket(conn, 'test_multipart_bucket')