diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index f948f0f552d31c3fe9a9577fb8f5e393bf8df5ea..7767e83f50849ee211ad525b4e0c5b869378df84 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -36,6 +36,7 @@
 
 namespace OCA\DAV\Connector\Sabre;
 
+use Icewind\Streams\CallbackWrapper;
 use OC\AppFramework\Http\Request;
 use OC\Files\Filesystem;
 use OC\Files\View;
@@ -166,10 +167,15 @@ class File extends Node implements IFile {
 			}
 
 			if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) {
-				$count = $partStorage->writeStream($internalPartPath, $data);
+				$isEOF = false;
+				$wrappedData = CallbackWrapper::wrap($data, null, null, null, null, function($stream) use (&$isEOF) {
+					$isEOF = feof($stream);
+				});
+
+				$count = $partStorage->writeStream($internalPartPath, $wrappedData);
 				$result = $count > 0;
 				if ($result === false) {
-					$result = feof($data);
+					$result = $isEOF;
 				}
 
 			} else {