Sabre\DAV\Exception: Error while copying file to target location

Nextcloud version : 15.0.2
Operating system and version : FreeNAS 11.2-RELEASE-U1
Apache or nginx version : Apache 2.4.38
PHP version : 7.2.14

The issue:

I have recenlty installed nextcloud and have found that when copying files via the web interface im faced with an error message.

'Error while copying file to target location (copied bytes: 0, expected filesize: 0 )'

This issue seems only to relate to web interface copying of data, specifically drag and droping files, or copying files larger than 5GB in size.
The sync via application works perfectly fine.
The external storage files work perfectly fine.
Im unsure where to go from here, anyone got some ideas?

Steps to replicate it:

Error happens when drag and drop new file called copy.txt into folder called ‘test2’.
Error also happens when large file (5GB) is copied from folder ‘test’ to ‘test2’.
Error also happens when large file (10GB) is copied from external storage folder to ‘test2’ folder.

No error happens when copy.txt is copied from folder ‘test’ to ‘test2’.
No error happens when when large file (1.8GB) is copied from external storage folder to ‘test2’ folder.

The output of your Nextcloud log in Admin > Logging:

[webdav] Fatal: Sabre\DAV\Exception: Error while copying file to target location (copied bytes: 0, expected filesize: 0 ) at <<closure>>

0. /usr/local/www/apache24/data/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php line 156
   put(null)
1. /usr/local/www/apache24/data/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1096
   createFile("copy.txt", null)
2. /usr/local/www/apache24/data/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 525
   createFile("test2/copy.txt", null, null)
3. <<closure>>
   httpPut(Sabre\HTTP\Reque ... "}, Sabre\HTTP\Response {})
4. /usr/local/www/apache24/data/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php line 105
   call_user_func_array([Sabre\DAV\CorePlugin {},"httpPut"], [Sabre\HTTP\Requ ... }])
5. /usr/local/www/apache24/data/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 479
   emit("method:PUT", [Sabre\HTTP\Requ ... }])
6. /usr/local/www/apache24/data/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 254
   invokeMethod(Sabre\HTTP\Reque ... "}, Sabre\HTTP\Response {})
7. /usr/local/www/apache24/data/nextcloud/apps/dav/appinfo/v1/webdav.php line 80
   exec()
8. /usr/local/www/apache24/data/nextcloud/remote.php line 163
   require_once("/usr/local/www/ ... p")

PUT /remote.php/webdav/test2/copy.txt
from 192.168.1.1 by User at 2019-01-29T19:27:42+00:00

The output of config.php:


<?php
$CONFIG = array (
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'domain.ddns.net',
    2 => '192.168.1.21',
  ),
  'datadirectory' => '/mnt/files',
  'quota_include_external_storage' => true,
  'dbtype' => 'mysql',
  'version' => '15.0.2.0',
  'overwrite.cli.url' => 'https://domain.ddns.net/',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:/tmp/mysql.sock',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => '***',
  'installed' => true,
  'instanceid' => 'ocgzhx1952cm',
  'logtimezone' => 'Europe/London',
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud.log',
  'loglevel' => '2',
  'logrotate_size' => '104847600',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'redis' =>
  array (
    'host' => '/tmp/redis.sock',
    'port' => 0,
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'htaccess.RewriteBase' => '/',
  'maintenance' => false,
  'theme' => '',
  'twofactor_enforced' => 'false',
  'twofactor_enforced_groups' =>
  array (
  ),
  'twofactor_enforced_excluded_groups' =>
  array (
  ),
);


The output /var/log/nextcloud.log (last chunk):

Id":"nqPlGRuDi7WuY89YKVEQ","level":3,"time":"2019-01-29T18:48:35+00:00","remoteAddr":"192.168.1.1","user":"User1","app":"PHP","method":"COPY","url":"\/remote.php\/dav\/files\/User1\/Home\/Documents","message":"feof(): supplied resource is not a valid stream resource at \/usr\/local\/www\/apache24\/data\/nextcloud\/apps\/dav\/lib\/Co$
{"reqId":"nqPlGRuDi7WuY89YKVEQ","level":3,"time":"2019-01-29T18:48:35+00:00","remoteAddr":"192.168.1.1","user":"User1","app":"no app in context","method":"COPY","url":"\/remote.php\/dav\/files\/User1\/Home\/Documents","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, e$
{"reqId":"nqPlGRuDi7WuY89YKVEQ","level":4,"time":"2019-01-29T18:48:35+00:00","remoteAddr":"192.168.1.1","user":"User1","app":"webdav","method":"COPY","url":"\/remote.php\/dav\/files\/User1\/Home\/Documents","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected fil$
{"reqId":"0Qsjn9rxHyQYiPIwdFHc","level":3,"time":"2019-01-29T18:49:17+00:00","remoteAddr":"192.168.1.1","user":"User1","app":"no app in context","method":"DELETE","url":"\/remote.php\/dav\/files\/User1\/test\/Documents","message":{"Exception":"OCP\\Lock\\LockedException","Message":"\"files\/15ff0c63af63c0209a251761f348bb1d\" is locked, e$
{"reqId":"7eoDgZ7QvWL6AwTbZ0Na","level":3,"time":"2019-01-29T18:49:39+00:00","remoteAddr":"192.168.1.1","user":"User1","app":"files_antivirus","method":"PUT","url":"\/remote.php\/webdav\/test\/dragme.txt","message":{"Exception":"RuntimeException","Message":"The antivirus executable could not be found at \/usr\/bin\/clamscan","Code":0,"Tra$
{"reqId":"7eoDgZ7QvWL6AwTbZ0Na","level":3,"time":"2019-01-29T18:49:39+00:00","remoteAddr":"192.168.1.1","user":"User1","app":"PHP","method":"PUT","url":"\/remote.php\/webdav\/test\/dragme.txt","message":"feof(): supplied resource is not a valid stream resource at \/usr\/local\/www\/apache24\/data\/nextcloud\/apps\/dav\/lib\/Connector\/Sab$
{"reqId":"7eoDgZ7QvWL6AwTbZ0Na","level":3,"time":"2019-01-29T18:49:39+00:00","remoteAddr":"192.168.1.1","user":"User1","app":"no app in context","method":"PUT","url":"\/remote.php\/webdav\/test\/dragme.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected file$
{"reqId":"7eoDgZ7QvWL6AwTbZ0Na","level":4,"time":"2019-01-29T18:49:39+00:00","remoteAddr":"192.168.1.1","user":"User1","app":"webdav","method":"PUT","url":"\/remote.php\/webdav\/test\/dragme.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected filesize: 0 )",$
{"reqId":"aLUM1Ar8nPsvvMyCTjT0","level":3,"time":"2019-01-29T18:52:16+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"files_antivirus","method":"PUT","url":"\/remote.php\/webdav\/test\/game\/game2\/copy.txt","message":{"Exception":"RuntimeException","Message":"The antivirus executable could not be found at \/usr\/bin\/clamscan","C$
{"reqId":"aLUM1Ar8nPsvvMyCTjT0","level":3,"time":"2019-01-29T18:52:16+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"PHP","method":"PUT","url":"\/remote.php\/webdav\/test\/game\/game2\/copy.txt","message":"feof(): supplied resource is not a valid stream resource at \/usr\/local\/www\/apache24\/data\/nextcloud\/apps\/dav\/lib\/Con$
{"reqId":"aLUM1Ar8nPsvvMyCTjT0","level":3,"time":"2019-01-29T18:52:16+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"no app in context","method":"PUT","url":"\/remote.php\/webdav\/test\/game\/game2\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, ex$
{"reqId":"aLUM1Ar8nPsvvMyCTjT0","level":4,"time":"2019-01-29T18:52:16+00:00","remoteAddr":"192.168.1.1","user":"USer2","app":"webdav","method":"PUT","url":"\/remote.php\/webdav\/test\/game\/game2\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected file$
{"reqId":"9uYDKljp7Tb0kAgy9flb","level":3,"time":"2019-01-29T18:55:05+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"PHP","method":"PUT","url":"\/remote.php\/webdav\/test\/test2\/copy.txt","message":"feof(): supplied resource is not a valid stream resource at \/usr\/local\/www\/apache24\/data\/nextcloud\/apps\/dav\/lib\/Connector$
{"reqId":"9uYDKljp7Tb0kAgy9flb","level":3,"time":"2019-01-29T18:55:05+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"no app in context","method":"PUT","url":"\/remote.php\/webdav\/test\/test2\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected$
{"reqId":"9uYDKljp7Tb0kAgy9flb","level":4,"time":"2019-01-29T18:55:05+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"webdav","method":"PUT","url":"\/remote.php\/webdav\/test\/test2\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected filesize: $
{"reqId":"E8kibG8qZoxeixPovmj4","level":3,"time":"2019-01-29T19:01:02+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"PHP","method":"PUT","url":"\/remote.php\/webdav\/test\/test2\/copy.txt","message":"feof(): supplied resource is not a valid stream resource at \/usr\/local\/www\/apache24\/data\/nextcloud\/apps\/dav\/lib\/Connector$
{"reqId":"E8kibG8qZoxeixPovmj4","level":3,"time":"2019-01-29T19:01:02+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"no app in context","method":"PUT","url":"\/remote.php\/webdav\/test\/test2\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected$
{"reqId":"E8kibG8qZoxeixPovmj4","level":4,"time":"2019-01-29T19:01:02+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"webdav","method":"PUT","url":"\/remote.php\/webdav\/test\/test2\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected filesize: $
{"reqId":"X3Vqigfi84S6UWyXEiBB","level":3,"time":"2019-01-29T19:22:44+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"PHP","method":"PUT","url":"\/remote.php\/webdav\/copy.txt","message":"feof(): supplied resource is not a valid stream resource at \/usr\/local\/www\/apache24\/data\/nextcloud\/apps\/dav\/lib\/Connector\/Sabre\/File$
{"reqId":"X3Vqigfi84S6UWyXEiBB","level":3,"time":"2019-01-29T19:22:44+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"no app in context","method":"PUT","url":"\/remote.php\/webdav\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected filesize: 0 $
{"reqId":"X3Vqigfi84S6UWyXEiBB","level":4,"time":"2019-01-29T19:22:44+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"webdav","method":"PUT","url":"\/remote.php\/webdav\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected filesize: 0 )","Code":0$
{"reqId":"ZHjJC170Zab5zAtbfJ00","level":3,"time":"2019-01-29T19:27:42+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"PHP","method":"PUT","url":"\/remote.php\/webdav\/test2\/copy.txt","message":"feof(): supplied resource is not a valid stream resource at \/usr\/local\/www\/apache24\/data\/nextcloud\/apps\/dav\/lib\/Connector\/Sabr$
{"reqId":"ZHjJC170Zab5zAtbfJ00","level":3,"time":"2019-01-29T19:27:42+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"no app in context","method":"PUT","url":"\/remote.php\/webdav\/test2\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected files$
{"reqId":"ZHjJC170Zab5zAtbfJ00","level":4,"time":"2019-01-29T19:27:42+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"webdav","method":"PUT","url":"\/remote.php\/webdav\/test2\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected filesize: 0 )","$
{"reqId":"lk5DeQV1zAzqJqgmzBur","level":3,"time":"2019-01-29T19:41:42+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"PHP","method":"PUT","url":"\/remote.php\/webdav\/copy.txt","message":"feof(): supplied resource is not a valid stream resource at \/usr\/local\/www\/apache24\/data\/nextcloud\/apps\/dav\/lib\/Connector\/Sabre\/File$
{"reqId":"lk5DeQV1zAzqJqgmzBur","level":3,"time":"2019-01-29T19:41:42+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"no app in context","method":"PUT","url":"\/remote.php\/webdav\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected filesize: 0 $
{"reqId":"lk5DeQV1zAzqJqgmzBur","level":4,"time":"2019-01-29T19:41:42+00:00","remoteAddr":"192.168.1.1","user":"User2","app":"webdav","method":"PUT","url":"\/remote.php\/webdav\/copy.txt","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected filesize: 0 )","Code":0$

Ok I think most of the issues I was having was related to this bug with the encryption. The txt files I used where 0 bytes so this caused an issue. This will be fixed in the next update.

Although specifically for me this is quite a major issue…I had to modify the php file manually because I cant wait another month for the next update.

https://github.com/nextcloud/server/pull/13468/files

Edit: After installing 'Antivirus for files ’ app, looks like the issue returns, even after editing the file above, any ideas?

I have the same problem and it seems to be related to Sabre Dav. My files are not syncing from desktop to server to desktop. An action taken on one desktop does not get synced to the server. Doesn’t matter how many desktops I do this with, it doesn’t happen.
Today, this error started happening. Files not syncing due to this Sabre/DAV/Exception but I then discovered it is not allowing the creation of shared folders.
It seems to be causing multiple problems for me. Can you post how you fixed it please?

Hi, I didnt realy fix it…just a dirty workaround, the link above displays file and the line to comment out, although it is proably included in a recent update. All I did was remove the 'Antivirus for files ’ app and comment the line in the file, and mine has been working fine for months.

1 Like

Hi

Thanks for your reply.

I am hosting my server online and the space available indicator was showing I had 90gbs available when I had no space available. It was that simple. The problem turned out that the recycle bin wasn’t being emptied. I have changed that now.

It was simple to fix and I went looking for the complicated answer!

Rich