Skip to content

Commit 8bee8e1

Browse files
authored
Merge pull request #21317 from FlorentCoppint/s3_upload_part_size
Upload part size as S3 parameter instead of constant value
2 parents 8925897 + 3594ba6 commit 8bee8e1

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

lib/private/Files/ObjectStore/S3ConnectionTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ trait S3ConnectionTrait {
4747

4848
/** @var int */
4949
protected $timeout;
50+
51+
/** @var int */
52+
protected $uploadPartSize;
5053

5154
protected $test;
5255

@@ -60,6 +63,7 @@ protected function parseParams($params) {
6063
$this->test = isset($params['test']);
6164
$this->bucket = $params['bucket'];
6265
$this->timeout = !isset($params['timeout']) ? 15 : $params['timeout'];
66+
$this->uploadPartSize = !isset($params['uploadPartSize']) ? 524288000 : $params['uploadPartSize'];
6367
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
6468
$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
6569
if (!isset($params['port']) || $params['port'] === '') {

lib/private/Files/ObjectStore/S3ObjectTrait.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
use Icewind\Streams\CallbackWrapper;
3434
use OC\Files\Stream\SeekableHttpStream;
3535

36-
const S3_UPLOAD_PART_SIZE = 524288000; // 500MB
37-
3836
trait S3ObjectTrait {
3937
/**
4038
* Returns the connection
@@ -91,7 +89,7 @@ public function writeObject($urn, $stream) {
9189
$uploader = new MultipartUploader($this->getConnection(), $countStream, [
9290
'bucket' => $this->bucket,
9391
'key' => $urn,
94-
'part_size' => S3_UPLOAD_PART_SIZE,
92+
'part_size' => $this->uploadPartSize,
9593
]);
9694

9795
try {

0 commit comments

Comments
 (0)