Merge pull request #34552 from nextcloud/backport/34537/stable24

[stable24] Avoid allocating too much memory for the buffer on s3 uploads
This commit is contained in:
Vincent Petry 2022-10-12 15:02:06 +02:00 committed by GitHub
commit 955bd21f7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -152,7 +152,7 @@ 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, $this->uploadPartSize);
Utils::copyToStream($psrStream, $buffer, $this->putSizeLimit);
$buffer->seek(0);
if ($buffer->getSize() < $this->putSizeLimit) {
// buffer is fully seekable, so use it directly for the small upload