Merge pull request #34537 from nextcloud/bugfix/noid/s3-upload-memory

Avoid allocating too much memory for the buffer on s3 uploads
This commit is contained in:
John Molakvoæ 2022-10-12 10:24:55 +02:00 committed by GitHub
commit d936694cdb
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