aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorStephan Orbaugh <62374139+sorbaugh@users.noreply.github.com>2024-07-25 12:58:06 +0200
committerGitHub <noreply@github.com>2024-07-25 12:58:06 +0200
commite79fa57b707ec4cb59767f852135d33b85a7ac0e (patch)
treebbc7f1fe3c836cbf178d3e07802cfe702af225de /apps
parentebfd4938f677c582c4c821d7f0cefc95b5344dc5 (diff)
parentc2b1f079b110c1f41df78faf0dbd44c3f87406c0 (diff)
downloadnextcloud-server-e79fa57b707ec4cb59767f852135d33b85a7ac0e.tar.gz
nextcloud-server-e79fa57b707ec4cb59767f852135d33b85a7ac0e.zip
Merge pull request #46693 from nextcloud/s3-writestream-impl
feat: add a specialized writeStream implementation for s3 external storage
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 5cb2c4ef1ef..895bd00c462 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -8,6 +8,7 @@ namespace OCA\Files_External\Lib\Storage;
use Aws\S3\Exception\S3Exception;
use Icewind\Streams\CallbackWrapper;
+use Icewind\Streams\CountWrapper;
use Icewind\Streams\IteratorDirectory;
use OC\Files\Cache\CacheEntry;
use OC\Files\ObjectStore\S3ConnectionTrait;
@@ -754,4 +755,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;
+ }
}