Debian Codegraph @

lib/3rdParty/composer/aws/aws-sdk-php/src/S3/S3Transfer/RangeGetMultipartDownloader.php

raw symbols SCIP
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 * @inheritDoc
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 * @inheritDoc
32 *
33 * @param Result $result
34 *
35 * @return void
36 */
37 protected function computeObjectDimensions(ResultInterface $result): void
38 {
39 // Assign object size just if needed.
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 // Single download since partSize will be set to full object size.
53 $this->objectPartsCount = 1;
54 $this->currentPartNo = 1;
55 }
56 }
57 }