Skip to content

Commit

Permalink
Fixed headers passing in Multipart upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mludvig committed Jan 5, 2012
1 parent 07ed770 commit f46250a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 3 additions & 2 deletions S3/MultiPart.py
Expand Up @@ -14,19 +14,20 @@ class MultiPartUpload(object):
MAX_CHUNK_SIZE_MB = 5120 # 5GB
MAX_FILE_SIZE = 42949672960 # 5TB

def __init__(self, s3, file, uri):
def __init__(self, s3, file, uri, headers_baseline = {}):
self.s3 = s3
self.file = file
self.uri = uri
self.parts = {}
self.headers_baseline = headers_baseline
self.upload_id = self.initiate_multipart_upload()

def initiate_multipart_upload(self):
"""
Begin a multipart upload
http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?mpUploadInitiate.html
"""
request = self.s3.create_request("OBJECT_POST", uri = self.uri, extra = "?uploads")
request = self.s3.create_request("OBJECT_POST", uri = self.uri, headers = self.headers_baseline, extra = "?uploads")
response = self.s3.send_request(request)
data = response["data"]
self.upload_id = getTextFromXml(data, "UploadId")
Expand Down
4 changes: 1 addition & 3 deletions S3/S3.py
Expand Up @@ -747,10 +747,8 @@ def send_file(self, request, file, labels, throttle = 0, retries = _max_retries,
return response

def send_file_multipart(self, file, headers, uri, size):
upload = MultiPartUpload(self, file, uri)

chunk_size = self.config.multipart_chunk_size_mb * 1024 * 1024

upload = MultiPartUpload(self, file, uri, headers)
upload.upload_all_parts()
response = upload.complete_multipart_upload()
response["speed"] = 0 # XXX
Expand Down

0 comments on commit f46250a

Please sign in to comment.