Skip to content

Commit

Permalink
Merge pull request #34552 from nextcloud/backport/34537/stable24
Browse files Browse the repository at this point in the history
[stable24] Avoid allocating too much memory for the buffer on s3 uploads
  • Loading branch information
PVince81 authored Oct 12, 2022
2 parents 38752c9 + 19ed7a5 commit 955bd21
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/private/Files/ObjectStore/S3ObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function writeObject($urn, $stream, string $mimetype = null) {
// ($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
Expand Down

0 comments on commit 955bd21

Please sign in to comment.