From f5fe5316657ee32caca74072b3b140577ef7c55b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 28 Dec 2023 15:31:08 +0100 Subject: [PATCH] fix(s3): Add config option to disable multipart copy for certain s3 providers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/Files/ObjectStore/S3ConnectionTrait.php | 3 +++ lib/private/Files/ObjectStore/S3ObjectTrait.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index 51d9f687a13b8..e6ed9c2ef5b8c 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -74,6 +74,8 @@ trait S3ConnectionTrait { /** @var int */ private $copySizeLimit; + private bool $useMultipartCopy = true; + protected $test; protected function parseParams($params) { @@ -91,6 +93,7 @@ protected function parseParams($params) { $this->uploadPartSize = $params['uploadPartSize'] ?? 524288000; $this->putSizeLimit = $params['putSizeLimit'] ?? 104857600; $this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000; + $this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true); $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'] === '') { diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php index 65952a76a6132..2ef9614ac85c3 100644 --- a/lib/private/Files/ObjectStore/S3ObjectTrait.php +++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php @@ -198,7 +198,7 @@ public function copyObject($from, $to, array $options = []) { $size = (int)($sourceMetadata->get('Size') ?? $sourceMetadata->get('ContentLength')); - if ($size > $this->copySizeLimit) { + if ($this->useMultipartCopy && $size > $this->copySizeLimit) { $copy = new MultipartCopy($this->getConnection(), [ "source_bucket" => $this->getBucket(), "source_key" => $from