Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(ObjectStore): Make S3 MultipartUpload concurrency configurable
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Mar 21, 2024
commit 32dee2f84a4931d4ed4544a68e95287948ee5db2
3 changes: 3 additions & 0 deletions lib/private/Files/ObjectStore/S3ConfigTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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