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

Class UploadPartTask

awscli/s3transfer/upload.py:803–844  ·  view source on GitHub ↗

Task to upload a part in a multipart upload

Source from the content-addressed store, hash-verified

801
802
803class UploadPartTask(Task):
804 """Task to upload a part in a multipart upload"""
805
806 def _main(
807 self, client, fileobj, bucket, key, upload_id, part_number, extra_args
808 ):
809 """
810 :param client: The client to use when calling PutObject
811 :param fileobj: The file to upload.
812 :param bucket: The name of the bucket to upload to
813 :param key: The name of the key to upload to
814 :param upload_id: The id of the upload
815 :param part_number: The number representing the part of the multipart
816 upload
817 :param extra_args: A dictionary of any extra arguments that may be
818 used in the upload.
819
820 :rtype: dict
821 :returns: A dictionary representing a part::
822
823 {'Etag': etag_value, 'PartNumber': part_number}
824
825 This value can be appended to a list to be used to complete
826 the multipart upload.
827 """
828 with fileobj as body:
829 response = client.upload_part(
830 Bucket=bucket,
831 Key=key,
832 UploadId=upload_id,
833 PartNumber=part_number,
834 Body=body,
835 **extra_args,
836 )
837 etag = response['ETag']
838 part_metadata = {'ETag': etag, 'PartNumber': part_number}
839 if 'ChecksumAlgorithm' in extra_args:
840 algorithm_name = extra_args['ChecksumAlgorithm'].upper()
841 checksum_member = f'Checksum{algorithm_name}'
842 if checksum_member in response:
843 part_metadata[checksum_member] = response[checksum_member]
844 return part_metadata

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected