MCPcopy Create free account
hub / github.com/aws/aws-cli / CopyPartTask

Class CopyPartTask

awscli/s3transfer/copies.py:342–414  ·  view source on GitHub ↗

Task to upload a part in a multipart copy

Source from the content-addressed store, hash-verified

340
341
342class CopyPartTask(Task):
343 """Task to upload a part in a multipart copy"""
344
345 def _main(
346 self,
347 client,
348 copy_source,
349 bucket,
350 key,
351 upload_id,
352 part_number,
353 extra_args,
354 callbacks,
355 size,
356 checksum_algorithm=None,
357 ):
358 """
359 :param client: The client to use when calling PutObject
360 :param copy_source: The CopySource parameter to use
361 :param bucket: The name of the bucket to upload to
362 :param key: The name of the key to upload to
363 :param upload_id: The id of the upload
364 :param part_number: The number representing the part of the multipart
365 upload
366 :param extra_args: A dictionary of any extra arguments that may be
367 used in the upload.
368 :param callbacks: List of callbacks to call after copy part
369 :param size: The size of the transfer. This value is passed into
370 the callbacks
371 :param checksum_algorithm: The algorithm that was used to create the multipart
372 upload
373
374 :rtype: dict
375 :returns: A dictionary representing a part::
376
377 {'Etag': etag_value, 'PartNumber': part_number}
378
379 This value can be appended to a list to be used to complete
380 the multipart upload. If a checksum is in the response,
381 it will also be included.
382 """
383 try:
384 response = client.upload_part_copy(
385 CopySource=copy_source,
386 Bucket=bucket,
387 Key=key,
388 UploadId=upload_id,
389 PartNumber=part_number,
390 **extra_args,
391 )
392 except ClientError as e:
393 error_code = e.response.get('Error', {}).get('Code')
394 src_key = copy_source['Key']
395 src_bucket = copy_source['Bucket']
396 if error_code == "PreconditionFailed":
397 raise S3CopyFailedError(
398 f'Contents of stored object "{src_key}" '
399 f'in bucket "{src_bucket}" did not match '

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected