mirror of
https://github.com/nextcloud/server.git
synced 2026-05-19 16:39:59 -04:00
Merge pull request #46741 from nextcloud/backport/46693/stable27
This commit is contained in:
commit
a3b7ec98be
1 changed files with 21 additions and 0 deletions
|
|
@ -43,6 +43,7 @@ use Aws\Result;
|
|||
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;
|
||||
|
|
@ -790,4 +791,24 @@ class AmazonS3 extends \OC\Files\Storage\Common {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue