]> source.dussan.org Git - nextcloud-server.git/commitdiff
Upload part size as S3 parameter instead of constant value 21317/head
authorFlorent <florent@coppint.com>
Mon, 8 Jun 2020 15:38:00 +0000 (17:38 +0200)
committerFlorent <florent@coppint.com>
Tue, 9 Jun 2020 07:18:42 +0000 (09:18 +0200)
Some S3 providers need a custom upload part size (500 MB static value in Nextcloud).
Here is a commit to change this value via S3 configuration, instead of using S3_UPLOAD_PART_SIZE constant.
A new parameter is added for an S3 connection : uploadPartSize

Signed-off-by: Florent <florent@coppint.com>
lib/private/Files/ObjectStore/S3ConnectionTrait.php
lib/private/Files/ObjectStore/S3ObjectTrait.php

index 5a61918223896b89f56c0c258d422426a6147cef..0208df1908a92f9140d5ef40e7756f01e094cd8b 100644 (file)
@@ -47,6 +47,9 @@ trait S3ConnectionTrait {
 
        /** @var int */
        protected $timeout;
+       
+       /** @var int */
+       protected $uploadPartSize;
 
        protected $test;
 
@@ -60,6 +63,7 @@ trait S3ConnectionTrait {
                $this->test = isset($params['test']);
                $this->bucket = $params['bucket'];
                $this->timeout = !isset($params['timeout']) ? 15 : $params['timeout'];
+               $this->uploadPartSize = !isset($params['uploadPartSize']) ? 524288000 : $params['uploadPartSize'];
                $params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
                $params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
                if (!isset($params['port']) || $params['port'] === '') {
index f749769cd09577277f22f7a0a5bcee1ed23b91d3..d7c878178d249b8643786a95a10edf50342680f5 100644 (file)
@@ -33,8 +33,6 @@ use Aws\S3\S3Client;
 use Icewind\Streams\CallbackWrapper;
 use OC\Files\Stream\SeekableHttpStream;
 
-const S3_UPLOAD_PART_SIZE = 524288000; // 500MB
-
 trait S3ObjectTrait {
        /**
         * Returns the connection
@@ -91,7 +89,7 @@ trait S3ObjectTrait {
                $uploader = new MultipartUploader($this->getConnection(), $countStream, [
                        'bucket' => $this->bucket,
                        'key' => $urn,
-                       'part_size' => S3_UPLOAD_PART_SIZE,
+                       'part_size' => $this->uploadPartSize,
                ]);
 
                try {