Task to initiate a multipart upload
| 330 | |
| 331 | |
| 332 | class CreateMultipartUploadTask(Task): |
| 333 | """Task to initiate a multipart upload""" |
| 334 | |
| 335 | def _main(self, client, bucket, key, extra_args): |
| 336 | """ |
| 337 | :param client: The client to use when calling CreateMultipartUpload |
| 338 | :param bucket: The name of the bucket to upload to |
| 339 | :param key: The name of the key to upload to |
| 340 | :param extra_args: A dictionary of any extra arguments that may be |
| 341 | used in the initialization. |
| 342 | |
| 343 | :returns: The upload id of the multipart upload |
| 344 | """ |
| 345 | # Create the multipart upload. |
| 346 | response = client.create_multipart_upload( |
| 347 | Bucket=bucket, Key=key, **extra_args |
| 348 | ) |
| 349 | upload_id = response['UploadId'] |
| 350 | |
| 351 | # Add a cleanup if the multipart upload fails at any point. |
| 352 | self._transfer_coordinator.add_failure_cleanup( |
| 353 | client.abort_multipart_upload, |
| 354 | Bucket=bucket, |
| 355 | Key=key, |
| 356 | UploadId=upload_id, |
| 357 | ) |
| 358 | return upload_id |
| 359 | |
| 360 | |
| 361 | class CompleteMultipartUploadTask(Task): |
no outgoing calls
no test coverage detected