in s3transfer/__init__.py [0:0]
def upload_file(self, filename, bucket, key, callback, extra_args):
response = self._client.create_multipart_upload(
Bucket=bucket, Key=key, **extra_args
)
upload_id = response['UploadId']
try:
parts = self._upload_parts(
upload_id, filename, bucket, key, callback, extra_args
)
except Exception as e:
logger.debug(
"Exception raised while uploading parts, "
"aborting multipart upload.",
exc_info=True,
)
self._client.abort_multipart_upload(
Bucket=bucket, Key=key, UploadId=upload_id
)
raise S3UploadFailedError(
"Failed to upload {} to {}: {}".format(
filename, '/'.join([bucket, key]), e
)
)
self._client.complete_multipart_upload(
Bucket=bucket,
Key=key,
UploadId=upload_id,
MultipartUpload={'Parts': parts},
)