Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/private/Files/ObjectStore/S3ObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,19 @@ public function writeObjectWithMetaData(string $urn, $stream, array $metaData):
// buffer is fully seekable, so use it directly for the small upload
$this->writeSingle($urn, $buffer, $metaData);
} else {
$loadStream = new Psr7\AppendStream([$buffer, $psrStream]);
if ($psrStream->isSeekable()) {
// If the body is seekable, just rewind the body.
$psrStream->rewind();
$loadStream = $psrStream;
} else {
// If the body is non-seekable, stitch the rewind the buffer and
// the partially read body together into one stream. This avoids
// unnecessary disk usage and does not require seeking on the
// original stream.
$buffer->rewind();
$loadStream = new Psr7\AppendStream([$buffer, $psrStream]);
}

$this->writeMultiPart($urn, $loadStream, $metaData);
}
} else {
Expand Down
Loading