Skip to content

Commit

Permalink
Merge pull request #46741 from nextcloud/backport/46693/stable27
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Jul 28, 2024
2 parents a6db0d3 + e21ddcf commit a3b7ec9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions apps/files_external/lib/Lib/Storage/AmazonS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use Aws\S3\Exception\S3Exception;
use Aws\S3\S3Client;
use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\CountWrapper;
use Icewind\Streams\IteratorDirectory;
use OCP\Cache\CappedMemoryCache;
use OC\Files\Cache\CacheEntry;
Expand Down Expand Up @@ -790,4 +791,24 @@ public function hasUpdated($path, $time) {
return true;
}
}

public function writeStream(string $path, $stream, ?int $size = null): int {
if ($size === null) {
$size = 0;
// track the number of bytes read from the input stream to return as the number of written bytes.
$stream = CountWrapper::wrap($stream, function (int $writtenSize) use (&$size) {
$size = $writtenSize;
});
}

if (!is_resource($stream)) {
throw new \InvalidArgumentException("Invalid stream provided");
}

$path = $this->normalizePath($path);
$this->writeObject($path, $stream, $this->mimeDetector->detectPath($path));
$this->invalidateCache($path);

return $size;
}
}

0 comments on commit a3b7ec9

Please sign in to comment.