Downloads an object and places content into io queue :param client: The client to use when calling GetObject :param bucket: The bucket to download from :param key: The key to download from :param fileobj: The file handle to write content to :param exta_args:
(
self,
client,
bucket,
key,
fileobj,
extra_args,
callbacks,
max_attempts,
download_output_manager,
io_chunksize,
start_index=0,
part_index=0,
bandwidth_limiter=None,
checksum_combiner=None,
)
| 594 | |
| 595 | class GetObjectTask(Task): |
| 596 | def _main( |
| 597 | self, |
| 598 | client, |
| 599 | bucket, |
| 600 | key, |
| 601 | fileobj, |
| 602 | extra_args, |
| 603 | callbacks, |
| 604 | max_attempts, |
| 605 | download_output_manager, |
| 606 | io_chunksize, |
| 607 | start_index=0, |
| 608 | part_index=0, |
| 609 | bandwidth_limiter=None, |
| 610 | checksum_combiner=None, |
| 611 | ): |
| 612 | """Downloads an object and places content into io queue |
| 613 | |
| 614 | :param client: The client to use when calling GetObject |
| 615 | :param bucket: The bucket to download from |
| 616 | :param key: The key to download from |
| 617 | :param fileobj: The file handle to write content to |
| 618 | :param exta_args: Any extra arguments to include in GetObject request |
| 619 | :param callbacks: List of progress callbacks to invoke on download |
| 620 | :param max_attempts: The number of retries to do when downloading |
| 621 | :param download_output_manager: The download output manager associated |
| 622 | with the current download. |
| 623 | :param io_chunksize: The size of each io chunk to read from the |
| 624 | download stream and queue in the io queue. |
| 625 | :param start_index: The location in the file to start writing the |
| 626 | content of the key to. |
| 627 | :param part_index: The part number for this ranged download. |
| 628 | :param bandwidth_limiter: The bandwidth limiter to use when throttling |
| 629 | the downloading of data in streams. |
| 630 | :param checksum_combiner: Optional FullObjectChecksumCombiner for |
| 631 | full object checksum validation on multipart downloads. |
| 632 | """ |
| 633 | last_exception = None |
| 634 | for i in range(max_attempts): |
| 635 | try: |
| 636 | current_index = start_index |
| 637 | response = client.get_object( |
| 638 | Bucket=bucket, Key=key, **extra_args |
| 639 | ) |
| 640 | self._validate_content_range( |
| 641 | extra_args.get('Range'), |
| 642 | response.get('ContentRange'), |
| 643 | ) |
| 644 | # When doing full object checksum combining and botocore |
| 645 | # hasn't already wrapped the body with a checksum |
| 646 | # calculator, wrap it in StreamingChecksumBody ourselves |
| 647 | # so the CRC is computed as data is read. We pass |
| 648 | # expected=None since we validate at the full object |
| 649 | # level, not per-part. |
| 650 | body = response['Body'] |
| 651 | if checksum_combiner is not None and not hasattr( |
| 652 | body, 'checksum' |
| 653 | ): |
nothing calls this directly
no test coverage detected