| 1 |
<?php |
| 2 |
|
| 3 |
namespace Aws\S3\S3Transfer; |
| 4 |
|
| 5 |
use Aws\CommandInterface; |
| 6 |
use Aws\Result; |
| 7 |
use Aws\ResultInterface; |
| 8 |
|
| 9 |
final class RangeGetMultipartDownloader extends AbstractMultipartDownloader |
| 10 |
{ |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
protected function getFetchCommandArgs(): array |
| 15 |
{ |
| 16 |
$nextCommandArgs = $this->downloadRequestArgs; |
| 17 |
$partSize = $this->config['target_part_size_bytes']; |
| 18 |
$from = ($this->currentPartNo - 1) * $partSize; |
| 19 |
$to = ($this->currentPartNo * $partSize) - 1; |
| 20 |
|
| 21 |
if ($this->objectSizeInBytes !== 0) { |
| 22 |
$to = min($this->objectSizeInBytes, $to); |
| 23 |
} |
| 24 |
|
| 25 |
$nextCommandArgs['Range'] = "bytes=$from-$to"; |
| 26 |
|
| 27 |
return $nextCommandArgs; |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
protected function computeObjectDimensions(ResultInterface $result): void |
| 38 |
{ |
| 39 |
|
| 40 |
if ($this->objectSizeInBytes === 0) { |
| 41 |
$this->objectSizeInBytes = self::computeObjectSizeFromContentRange( |
| 42 |
$result['ContentRange'] ?? "" |
| 43 |
); |
| 44 |
} |
| 45 |
|
| 46 |
$partSize = $this->config['target_part_size_bytes']; |
| 47 |
if ($this->objectSizeInBytes > $partSize) { |
| 48 |
$this->objectPartsCount = intval( |
| 49 |
ceil($this->objectSizeInBytes / $partSize) |
| 50 |
); |
| 51 |
} else { |
| 52 |
|
| 53 |
$this->objectPartsCount = 1; |
| 54 |
$this->currentPartNo = 1; |
| 55 |
} |
| 56 |
} |
| 57 |
} |