File tree Expand file tree Collapse file tree
apps/files_external/lib/Lib/Storage Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343use Aws \S3 \Exception \S3Exception ;
4444use Aws \S3 \S3Client ;
4545use Icewind \Streams \CallbackWrapper ;
46+ use Icewind \Streams \CountWrapper ;
4647use Icewind \Streams \IteratorDirectory ;
4748use OCP \Cache \CappedMemoryCache ;
4849use OC \Files \Cache \CacheEntry ;
@@ -790,4 +791,24 @@ public function hasUpdated($path, $time) {
790791 return true ;
791792 }
792793 }
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+ }
793814}
You can’t perform that action at this time.
0 commit comments