Skip to content

Commit 67e17de

Browse files
committed
feat(ObjectStore): Make S3 MultipartUpload concurrency configurable
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 4b282ea commit 67e17de

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lib/private/Files/ObjectStore/S3ConfigTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ trait S3ConfigTrait {
3131

3232
protected string $bucket;
3333

34+
/** Maximum number of concurrent multipart uploads */
35+
protected int $concurrency;
36+
3437
protected int $timeout;
3538

3639
protected string $proxy;

lib/private/Files/ObjectStore/S3ConnectionTrait.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ trait S3ConnectionTrait {
4848

4949
protected string $id;
5050

51-
protected ?S3Client $connection;
52-
5351
protected bool $test;
5452

53+
protected ?S3Client $connection = null;
54+
5555
protected function parseParams($params) {
5656
if (empty($params['bucket'])) {
5757
throw new \Exception("Bucket has to be configured.");
@@ -61,6 +61,8 @@ protected function parseParams($params) {
6161

6262
$this->test = isset($params['test']);
6363
$this->bucket = $params['bucket'];
64+
// Default to 5 like the S3 SDK does
65+
$this->concurrency = $params['concurrency'] ?? 5;
6466
$this->proxy = $params['proxy'] ?? false;
6567
$this->timeout = $params['timeout'] ?? 15;
6668
$this->storageClass = !empty($params['storageClass']) ? $params['storageClass'] : 'STANDARD';
@@ -92,7 +94,7 @@ public function getProxy() {
9294
* @throws \Exception if connection could not be made
9395
*/
9496
public function getConnection() {
95-
if (!is_null($this->connection)) {
97+
if ($this->connection !== null) {
9698
return $this->connection;
9799
}
98100

lib/private/Files/ObjectStore/S3ObjectTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ protected function writeSingle(string $urn, StreamInterface $stream, string $mim
129129
protected function writeMultiPart(string $urn, StreamInterface $stream, string $mimetype = null): void {
130130
$uploader = new MultipartUploader($this->getConnection(), $stream, [
131131
'bucket' => $this->bucket,
132+
'concurrency' => $this->concurrency,
132133
'key' => $urn,
133134
'part_size' => $this->uploadPartSize,
134135
'params' => [

0 commit comments

Comments
 (0)