Calculate the range parameter for multipart downloads/copies :type part_size: int :param part_size: The size of the part :type part_index: int :param part_index: The index for which this parts starts. This index starts at zero :type num_parts: int :param num_parts:
(
part_size, part_index, num_parts, total_size=None
)
| 69 | |
| 70 | |
| 71 | def calculate_range_parameter( |
| 72 | part_size, part_index, num_parts, total_size=None |
| 73 | ): |
| 74 | """Calculate the range parameter for multipart downloads/copies |
| 75 | |
| 76 | :type part_size: int |
| 77 | :param part_size: The size of the part |
| 78 | |
| 79 | :type part_index: int |
| 80 | :param part_index: The index for which this parts starts. This index starts |
| 81 | at zero |
| 82 | |
| 83 | :type num_parts: int |
| 84 | :param num_parts: The total number of parts in the transfer |
| 85 | |
| 86 | :returns: The value to use for Range parameter on downloads or |
| 87 | the CopySourceRange parameter for copies |
| 88 | """ |
| 89 | # Used to calculate the Range parameter |
| 90 | start_range = part_index * part_size |
| 91 | if part_index == num_parts - 1: |
| 92 | end_range = '' |
| 93 | if total_size is not None: |
| 94 | end_range = str(total_size - 1) |
| 95 | else: |
| 96 | end_range = start_range + part_size - 1 |
| 97 | range_param = f'bytes={start_range}-{end_range}' |
| 98 | return range_param |
| 99 | |
| 100 | |
| 101 | def get_callbacks(transfer_future, callback_type): |
no outgoing calls