diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-02-18 15:39:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-18 15:39:17 +0100 |
commit | f6f002e2ad46f7eb48c3e7a131236be5466a239a (patch) | |
tree | a2da71aa5772da3c9b9999a7bbe40cc10c52ea23 /apps/dav | |
parent | 49e8093e15fb0626f32002da7cf73b7789f1a7d4 (diff) | |
parent | fc967a5ac2dee93376685d4fe9faababafe55491 (diff) | |
download | nextcloud-server-f6f002e2ad46f7eb48c3e7a131236be5466a239a.tar.gz nextcloud-server-f6f002e2ad46f7eb48c3e7a131236be5466a239a.zip |
Merge pull request #14210 from nextcloud/fix/14192/fix_empty_uploads
Fix empty file uploads to S3 (and other streaming storages)
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/File.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index f948f0f552d..388bcff9206 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,22 @@ class File extends Node implements IFile { } if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) { - $count = $partStorage->writeStream($internalPartPath, $data); + + if (!is_resource($data)) { + $data = fopen('php://temp', 'r+'); + fwrite($data, 'foobar'); + rewind($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 { |