-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: Added part_size param to transfer manager for MultipartUploader. #3118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
59f48d2
be806cf
89fdc74
2fcf82b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ class Transfer implements PromisorInterface | |
| private $sourceMetadata; | ||
| private $destination; | ||
| private $concurrency; | ||
| private $partSize; | ||
| private $mupThreshold; | ||
| private $before; | ||
| private $after; | ||
|
|
@@ -118,6 +119,9 @@ public function __construct( | |
| $this->concurrency = isset($options['concurrency']) | ||
| ? $options['concurrency'] | ||
| : MultipartUploader::DEFAULT_CONCURRENCY; | ||
| $this->partSize = isset($options['part_size']) | ||
| ? $options['part_size'] | ||
| : MultipartUploader::PART_MIN_SIZE; | ||
|
Comment on lines
+122
to
+124
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be some validation here against |
||
| $this->mupThreshold = isset($options['mup_threshold']) | ||
| ? $options['mup_threshold'] | ||
| : 16777216; | ||
|
|
@@ -387,6 +391,7 @@ private function uploadMultipart($filename) | |
| 'before_upload' => $this->before, | ||
| 'before_complete' => $this->before, | ||
| 'concurrency' => $this->concurrency, | ||
| 'part_size' => $this->partSize, | ||
| 'add_content_md5' => $this->addContentMD5 | ||
| ]))->promise(); | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a couple more tests following the validation suggestions above |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -253,6 +253,40 @@ public function testDoesMultipartForLargeFilesWithFileInfoAsSource() | |
| `rm -rf $dir`; | ||
| } | ||
|
|
||
| public function testMultipartForLargeFilesDoesUsePartSize() | ||
| { | ||
| $s3 = $this->getTestClient('s3'); | ||
| $this->addMockResults($s3, [ | ||
| new Result(['UploadId' => '123']), | ||
| new Result(['ETag' => 'a']), | ||
| new Result(['ETag' => 'b']), | ||
| new Result(['UploadId' => '123']), | ||
| ]); | ||
|
|
||
| $dir = sys_get_temp_dir() . '/unittest'; | ||
| `rm -rf $dir`; | ||
| mkdir($dir); | ||
| $filename = new SplFileInfo($dir . '/large.txt'); | ||
| $f = fopen($filename, 'w+'); | ||
| $line = str_repeat('.', 1024); | ||
| for ($i = 0; $i < 20000; $i++) { | ||
| fwrite($f, $line); | ||
| } | ||
| fclose($f); | ||
|
|
||
| $res = fopen('php://temp', 'r+'); | ||
| $t = new Transfer($s3, $dir, 's3://foo/bar', [ | ||
| 'part_size' => 1024 * 1024 * 10, | ||
| 'debug' => $res | ||
| ]); | ||
|
|
||
| $t->transfer(); | ||
| rewind($res); | ||
| $output = stream_get_contents($res); | ||
| $this->assertStringNotContainsString("Transferring $filename -> s3://foo/bar/large.txt (UploadPart) : Part=3", $output); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test asserts only the absence of a Part=3 line. better to assert positively or via mock command capture ( |
||
| `rm -rf $dir`; | ||
| } | ||
|
|
||
| public function testDownloadsObjects() | ||
| { | ||
| $s3 = $this->getTestClient('s3'); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
part_sizeis missing a docblock entry in the "The options array can contain the following key value pairs..." section