Android upload sometimes fails

Nextcloud version (eg, 12.0.2): 13.0.8
Operating system and version (eg, Ubuntu 17.04): Debian Jessie
Apache or nginx version (eg, Apache 2.4.25): nginx 1.14
PHP version (eg, 7.1): 7.0.33

The issue you are facing:

Android upload sometimes fails due to inaccessible files

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Have a bunch of files in upload backlog from 3.5.0 android client
  2. Connect
  3. See about 50% of the uploads fail

The output of your Nextcloud log in Admin > Logging:

{"reqId":"2YPAFkYWJM3GIbsfrX2b","level":3,"time":"2019-03-07T22:07:17+00:00","remoteAddr":"<REDACTED>","user":"<REDACTED>","app":"PHP","method":"MOVE","url":"\/remote.php\/dav\/uploads\/<REDACTED>\/-1318735863\/.file","message":"fopen(\/var\/www\/nextcloud\/data\/<REDACTED>\/uploads\/-1318735863\/0000000000000000-0000000006639264): failed to open stream: No such file or directory at \/var\/www\/nextcloud\/lib\/private\/Files\/Storage\/Local.php#282","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.5.0","version":"13.0.8.2"}
{"reqId":"2YPAFkYWJM3GIbsfrX2b","level":4,"time":"2019-03-07T22:07:17+00:00","remoteAddr":"<REDACTED>","user":"REDACTED>","app":"webdav","method":"MOVE","url":"\/remote.php\/dav\/uploads\/<REDACTED>\/-1318735863\/.file","message":"Exception: {\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\ServiceUnavailable\",\"Message\":\"Could not open file\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Upload\\\/AssemblyStream.php(249): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->get()\\n#1 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Upload\\\/AssemblyStream.php(105): OCA\\\\DAV\\\\Upload\\\\AssemblyStream->getStream(Object(OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File))\\n#2 [internal function]: OCA\\\\DAV\\\\Upload\\\\AssemblyStream->stream_read(8192)\\n#3 \\\/var\\\/www\\\/nextcloud\\\/lib\\\/private\\\/legacy\\\/helper.php(297): fread(Resource id #26, 8192)\\n#4 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php(172): OC_Helper::streamCopy(Resource id #26, Resource id #27)\\n#5 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/Directory.php(156): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->put(Resource id #26)\\n#6 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Tree.php(314): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Directory->createFile('IMG_20190206_11...', Resource id #26)\\n#7 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Tree.php(130): Sabre\\\\DAV\\\\Tree->copyNode(Object(OCA\\\\DAV\\\\Upload\\\\FutureFile), Object(OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Directory), 'IMG_20190206_11...')\\n#8 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Tree.php(161): Sabre\\\\DAV\\\\Tree->copy('uploads\\\/nivo\\\/-1...', 'files\\\/nivo\\\/Inst...')\\n#9 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(646): Sabre\\\\DAV\\\\Tree->move('uploads\\\/nivo\\\/-1...', 'files\\\/nivo\\\/Inst...')\\n#10 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpMove(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#11 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#12 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:MOVE', Array)\\n#13 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#14 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Server.php(293): Sabre\\\\DAV\\\\Server->exec()\\n#15 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/appinfo\\\/v2\\\/remote.php(35): OCA\\\\DAV\\\\Server->exec()\\n#16 \\\/var\\\/www\\\/nextcloud\\\/remote.php(164): require_once('\\\/var\\\/www\\\/nextcl...')\\n#17 {main}\",\"File\":\"\\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php\",\"Line\":345}","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.5.0","version":"13.0.8.2"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '<REDACTED>',
  'overwritehost' => '<REDACTED>',
  'overwritewebroot' => '',
  'passwordsalt' => '<REDACTED>',
  'secret' => '<REDACTED>',
  'trusted_domains' =>
  array (
    0 => '<REDACTED>',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'overwrite.cli.url' => '<REDACTED>',
  'dbtype' => 'mysql',
  'version' => '13.0.8.2',
  <REDACTED DB SETTINGS>
  'logtimezone' => 'UTC',
  'installed' => true,
  'memcache.local' => '\OC\Memcache\APCu',
  'ldapIgnoreNamingRules' => false,
  'mail_smtpmode' => 'sendmail',
  'mail_from_address' => '<REDACTED>',
  'mail_domain' => '<REDACTED>',
  'loglevel' => 1,
  'default_language' => 'nl',
  'defaultapp' => 'files',
  'trashbin_retention_obligation' => 'auto, 90',
  'appstore.experimental.enabled' => true,
  'asset-pipeline.enabled' => true,
  'trusted_proxies' =>
  array (
    0 => '<REDACTED>',
  ),
  'forwarded_for_headers' =>
  array (
    0 => 'HTTP_X_FORWARDED',
    1 => 'HTTP_FORWARDED_FOR',
  ),
  'activity_expire_days' => 185,
  'maintenance' => false,
  'updatechecker' => true,
  'log_rotate_size' => 104857600,
  'theme' => '',
  'share_folder' => '/Shared with me',
  'updater.release.channel' => 'stable',
  'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory',
  'versions_retention_obligation' => 'auto, 90',
  'auth.bruteforce.protection.enabled' => false,
);

The output of your Apache/nginx/system log in /var/log/____:

Nothing of interest here

Android client fails the upload with message ‘Server is in maintenance mode’, which it clearly is not.
Output of status.php:

{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"13.0.8.2","versionstring":"13.0.8","edition":"","productname":"<REDACTED>"}