Skip to content

Commit 4aa47d6

Browse files
committed
Make max size for single put uploads configurable
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 3866f38 commit 4aa47d6

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/private/Files/ObjectStore/S3ConnectionTrait.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use Aws\Credentials\Credentials;
3737
use Aws\Exception\CredentialsException;
3838
use Aws\S3\Exception\S3Exception;
39+
use Aws\S3\MultipartUploader;
3940
use Aws\S3\S3Client;
4041
use GuzzleHttp\Promise;
4142
use GuzzleHttp\Promise\RejectedPromise;
@@ -63,6 +64,9 @@ trait S3ConnectionTrait {
6364
/** @var int */
6465
protected $uploadPartSize;
6566

67+
/** @var int */
68+
private $putSizeLimit;
69+
6670
protected $test;
6771

6872
protected function parseParams($params) {
@@ -77,6 +81,7 @@ protected function parseParams($params) {
7781
$this->proxy = $params['proxy'] ?? false;
7882
$this->timeout = $params['timeout'] ?? 15;
7983
$this->uploadPartSize = $params['uploadPartSize'] ?? 524288000;
84+
$this->putSizeLimit = $params['putSizeLimit'] ?? MultipartUploader::PART_MIN_SIZE;
8085
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
8186
$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
8287
if (!isset($params['port']) || $params['port'] === '') {

lib/private/Files/ObjectStore/S3ObjectTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function writeObject($urn, $stream, string $mimetype = null) {
146146
$buffer = new Psr7\Stream(fopen("php://memory", 'rwb+'));
147147
Utils::copyToStream($psrStream, $buffer, MultipartUploader::PART_MIN_SIZE);
148148
$buffer->seek(0);
149-
if ($buffer->getSize() < MultipartUploader::PART_MIN_SIZE) {
149+
if ($buffer->getSize() < $this->putSizeLimit) {
150150
// buffer is fully seekable, so use it directly for the small upload
151151
$this->writeSingle($urn, $buffer, $mimetype);
152152
} else {

0 commit comments

Comments
 (0)