예제 #1
0
    k.set_contents_from_file(fp, rewind=True)

cont =  k.get_contents_as_string()
test_util.assert_eq( '1'*1024, cont, 'test set_contents_from_file')

#test md5
md5 = hashlib.md5('1'*1024).hexdigest()
test_util.assert_eq( md5, k.md5,  'test k.md5')

os.remove("file_w1")
k.delete()

#test set_contents_from_filename
k = Key(b, 'key_1')
create_file('file_w2', '2'*1024)
k.set_contents_from_filename('file_w2')

cont =  k.get_contents_as_string()
test_util.assert_eq( cont, '2'*1024,  'test set_contents_from_filename')
os.remove("file_w2")

#test copy
b2 = conn.create_bucket('test_bucket_2')
k2 = k.copy('test_bucket_2', 'key_2')
cont =  k2.get_contents_as_string()
test_util.assert_eq( cont, '2'*1024,  'test copy')

#test exists
res1 = k.exists()
k.delete()
res2 = k.exists()
예제 #2
0
conn.head_bucket('tmpbucket0')

'tmpbucket0' in conn

keys = b0.get_all_keys()
for k in keys:
    print k.name

bucket = conn.get_bucket('tmpbucket0')

k0 = bucket.new_key('key0')
k0.set_contents_from_string('hello key0')

k1 = Key(bucket, 'key1')
k1.set_contents_from_filename('./tmp/file_w1')

k0 = bucket.get_key('key0')
cont =  k0.get_contents_as_string()
print cont

k1 = Key(bucket, 'key1')
k1.get_contents_to_filename('./tmp/file_r1')

bucket.delete_key('key0')

bucket.lookup('key0')

print k1.generate_url(expires_in = 300)

mp = bucket.initiate_multipart_upload('tmpmultipartkey')