diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index fe301d937297a1b673a2328136ac32fdf409e750..3c42f66a04afe595b44f269af3a6f4b991dcf7d7 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -169,9 +169,12 @@ class File extends Node implements IFile {
 			if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) {
 
 				if (!is_resource($data)) {
-					$data = fopen('php://temp', 'r+');
-					fwrite($data, 'foobar');
-					rewind($data);
+					$tmpData = fopen('php://temp', 'r+');
+					if ($data !== null) {
+						fwrite($tmpData, $data);
+						rewind($tmpData);
+					}
+					$data = $tmpData;
 				}
 
 				$isEOF = false;