Beginning of multipart upload support.
This commit is contained in:
parent
756955b61e
commit
f557487e06
3 changed files with 101 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import urllib2
|
||||
from io import BytesIO
|
||||
|
||||
import boto
|
||||
from boto.exception import S3ResponseError
|
||||
|
|
@ -36,6 +37,26 @@ def test_my_model_save():
|
|||
conn.get_bucket('mybucket').get_key('steve').get_contents_as_string().should.equal('is awesome')
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_multipart_upload():
|
||||
conn = boto.connect_s3('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
||||
multipart = bucket.initiate_multipart_upload("the-key")
|
||||
multipart.upload_part_from_file(BytesIO('hello'), 1)
|
||||
multipart.upload_part_from_file(BytesIO('world'), 1)
|
||||
# Multipart with total size under 5MB is refused
|
||||
multipart.complete_upload().should.throw(S3ResponseError)
|
||||
|
||||
multipart = bucket.initiate_multipart_upload("the-key")
|
||||
part1 = '0' * 5242880
|
||||
multipart.upload_part_from_file(BytesIO('0' * 5242880), 1)
|
||||
part2 = '1'
|
||||
multipart.upload_part_from_file(BytesIO('1'), 1)
|
||||
multipart.complete_upload()
|
||||
bucket.get_key("the-key").get_contents_as_string().should.equal(part1 + part2)
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_missing_key():
|
||||
conn = boto.connect_s3('the_key', 'the_secret')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue