copies_9.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. def _main(
  2. self,
  3. client,
  4. copy_source,
  5. bucket,
  6. key,
  7. upload_id,
  8. part_number,
  9. extra_args,
  10. callbacks,
  11. size,
  12. ):
  13. """
  14. :param client: The client to use when calling PutObject
  15. :param copy_source: The CopySource parameter to use
  16. :param bucket: The name of the bucket to upload to
  17. :param key: The name of the key to upload to
  18. :param upload_id: The id of the upload
  19. :param part_number: The number representing the part of the multipart
  20. upload
  21. :param extra_args: A dictionary of any extra arguments that may be
  22. used in the upload.
  23. :param callbacks: List of callbacks to call after copy part
  24. :param size: The size of the transfer. This value is passed into
  25. the callbacks
  26. :rtype: dict
  27. :returns: A dictionary representing a part::
  28. {'Etag': etag_value, 'PartNumber': part_number}
  29. This value can be appended to a list to be used to complete
  30. the multipart upload.
  31. """
  32. response = client.upload_part_copy(
  33. CopySource=copy_source,
  34. Bucket=bucket,
  35. Key=key,
  36. UploadId=upload_id,
  37. PartNumber=part_number,
  38. **extra_args
  39. )
  40. for callback in callbacks:
  41. callback(bytes_transferred=size)
  42. etag = response['CopyPartResult']['ETag']
  43. return {'ETag': etag, 'PartNumber': part_number}