Skip to content

Commit

Permalink
feat(ObjectStore): Make S3 MultipartUpload concurrency configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Mar 16, 2024
1 parent 4b282ea commit 67e17de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/private/Files/ObjectStore/S3ConfigTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ trait S3ConfigTrait {

protected string $bucket;

/** Maximum number of concurrent multipart uploads */
protected int $concurrency;

protected int $timeout;

protected string $proxy;
Expand Down
8 changes: 5 additions & 3 deletions lib/private/Files/ObjectStore/S3ConnectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ trait S3ConnectionTrait {

protected string $id;

protected ?S3Client $connection;

protected bool $test;

protected ?S3Client $connection = null;

protected function parseParams($params) {
if (empty($params['bucket'])) {
throw new \Exception("Bucket has to be configured.");
Expand All @@ -61,6 +61,8 @@ protected function parseParams($params) {

$this->test = isset($params['test']);
$this->bucket = $params['bucket'];
// Default to 5 like the S3 SDK does
$this->concurrency = $params['concurrency'] ?? 5;
$this->proxy = $params['proxy'] ?? false;
$this->timeout = $params['timeout'] ?? 15;
$this->storageClass = !empty($params['storageClass']) ? $params['storageClass'] : 'STANDARD';
Expand Down Expand Up @@ -92,7 +94,7 @@ public function getProxy() {
* @throws \Exception if connection could not be made
*/
public function getConnection() {
if (!is_null($this->connection)) {
if ($this->connection !== null) {
return $this->connection;
}

Expand Down
1 change: 1 addition & 0 deletions lib/private/Files/ObjectStore/S3ObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ protected function writeSingle(string $urn, StreamInterface $stream, string $mim
protected function writeMultiPart(string $urn, StreamInterface $stream, string $mimetype = null): void {
$uploader = new MultipartUploader($this->getConnection(), $stream, [
'bucket' => $this->bucket,
'concurrency' => $this->concurrency,
'key' => $urn,
'part_size' => $this->uploadPartSize,
'params' => [
Expand Down

0 comments on commit 67e17de

Please sign in to comment.