]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make max size for single put uploads configurable 28542/head
authorJulius Härtl <jus@bitgrid.net>
Fri, 20 Aug 2021 15:05:49 +0000 (17:05 +0200)
committerJulius Härtl <jus@bitgrid.net>
Wed, 29 Dec 2021 12:30:22 +0000 (13:30 +0100)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
lib/private/Files/ObjectStore/S3ConnectionTrait.php
lib/private/Files/ObjectStore/S3ObjectTrait.php

index 9dee98ba73607318b0c8c9d26b07aa68f197a3e3..b72b0ebee537259b429075d3b0978a1d1ad11176 100644 (file)
@@ -62,6 +62,9 @@ trait S3ConnectionTrait {
        /** @var int */
        protected $uploadPartSize;
 
+       /** @var int */
+       private $putSizeLimit;
+
        protected $test;
 
        protected function parseParams($params) {
@@ -76,6 +79,7 @@ trait S3ConnectionTrait {
                $this->proxy = $params['proxy'] ?? false;
                $this->timeout = $params['timeout'] ?? 15;
                $this->uploadPartSize = $params['uploadPartSize'] ?? 524288000;
+               $this->putSizeLimit = $params['putSizeLimit'] ?? 104857600;
                $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 01da7a88dc8f121e135fc2afffd99b02fd0763ba..769901acc79d7c3a0ba26aabbb015a69232adb06 100644 (file)
@@ -144,9 +144,9 @@ trait S3ObjectTrait {
                // ($psrStream->isSeekable() && $psrStream->getSize() !== null) evaluates to true for a On-Seekable stream
                // so the optimisation does not apply
                $buffer = new Psr7\Stream(fopen("php://memory", 'rwb+'));
-               Utils::copyToStream($psrStream, $buffer, MultipartUploader::PART_MIN_SIZE);
+               Utils::copyToStream($psrStream, $buffer, $this->uploadPartSize);
                $buffer->seek(0);
-               if ($buffer->getSize() < MultipartUploader::PART_MIN_SIZE) {
+               if ($buffer->getSize() < $this->putSizeLimit) {
                        // buffer is fully seekable, so use it directly for the small upload
                        $this->writeSingle($urn, $buffer, $mimetype);
                } else {