File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
apps/files_external/lib/Lib/Storage Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 43
43
use Aws \S3 \Exception \S3Exception ;
44
44
use Aws \S3 \S3Client ;
45
45
use Icewind \Streams \CallbackWrapper ;
46
+ use Icewind \Streams \CountWrapper ;
46
47
use Icewind \Streams \IteratorDirectory ;
47
48
use OCP \Cache \CappedMemoryCache ;
48
49
use OC \Files \Cache \CacheEntry ;
@@ -790,4 +791,24 @@ public function hasUpdated($path, $time) {
790
791
return true ;
791
792
}
792
793
}
794
+
795
+ public function writeStream (string $ path , $ stream , ?int $ size = null ): int {
796
+ if ($ size === null ) {
797
+ $ size = 0 ;
798
+ // track the number of bytes read from the input stream to return as the number of written bytes.
799
+ $ stream = CountWrapper::wrap ($ stream , function (int $ writtenSize ) use (&$ size ) {
800
+ $ size = $ writtenSize ;
801
+ });
802
+ }
803
+
804
+ if (!is_resource ($ stream )) {
805
+ throw new \InvalidArgumentException ("Invalid stream provided " );
806
+ }
807
+
808
+ $ path = $ this ->normalizePath ($ path );
809
+ $ this ->writeObject ($ path , $ stream , $ this ->mimeDetector ->detectPath ($ path ));
810
+ $ this ->invalidateCache ($ path );
811
+
812
+ return $ size ;
813
+ }
793
814
}
You can’t perform that action at this time.
0 commit comments