Upload fails on files bigger then 2GB - Anothertime: Sabre\DAV\Exception\BadRequest: expected filesize

Nextcloud version: 13.0.1
Operating system and version: Arch Linux with Yaourt
Apache or nginx version: Apache 2.4.29
PHP version: 7.2.3
Using MariaDB with Redis and APCu, Accessing over HTTPS with LetsEncrypt Cert.

The issue you are facing:
I couldn’t upload large files, bigger then about 2GB. I’ve set up that temp-files where put on the same disk as the nextcloud_data-files. There is enough space, all settings where I could limit the file and upload sizes are limited to 16GB. A file with 1.6GB is working, 2.1GB not. Even if I upload multiple files with 1.6GB it is working.

Is this the first time you’ve seen this error?: N (A few versions ago I fixed it)

Steps to replicate it:

  1. Upload file lager then round about 2GB via webdav.

The output of your Nextcloud log in Admin > Logging:

Sabre\DAV\Exception\BadRequest: expected filesize 2241229968 got 0

    /usr/share/webapps/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php - line 151: OCA\DAV\Connector\Sabre\File->put(Resource id #18)
    /usr/share/webapps/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 1096: OCA\DAV\Connector\Sabre\Directory->createFile('Mythos Stonehen...', Resource id #18)
    /usr/share/webapps/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 525: Sabre\DAV\Server->createFile('Anwendungen/Spi...', Resource id #18, NULL)
    [internal function] Sabre\DAV\CorePlugin->httpPut(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
    /usr/share/webapps/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
    /usr/share/webapps/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 479: Sabre\Event\EventEmitter->emit('method PUT', Array)
    /usr/share/webapps/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
    /usr/share/webapps/nextcloud/apps/dav/appinfo/v1/webdav.php - line 80: Sabre\DAV\Server->exec()
    /usr/share/webapps/nextcloud/remote.php - line 164: require_once('/usr/share/weba...')
    {main}

My nc conf:

<?php
$CONFIG = array (
  'instanceid' => 'BLUBB',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/usr/share/webapps/nextcloud/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/usr/share/webapps/nextcloud/apps_writeable',
      'url' => '/apps_writeable',
      'writable' => true,
    ),
  ),
  'datadirectory' => '/media/HDD5000GB/nextcloud_data',
  'passwordsalt' => 'BLUBB',
  'secret' => 'BLUBB',
  'trusted_domains' =>
  array (
    0 => 'BLUBB',
  ),
  'overwrite.cli.url' => 'BLUBB',
  'dbtype' => 'mysql',
  'version' => '13.0.1.1',
  'dbname' => 'BLUBB',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'BLUBB',
  'dbpassword' => 'BLUBB',
  'installed' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),
  'theme' => '',
  'loglevel' => 2,
  'maintenance' => false,
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
);

The output of your Apache access log:

PUT /remote.php/webdav/Anwendungen/Spiele/Testfile.ts HTTP/1.1" 413 1252

Apache error log:

Nothing apperes here if the error occourese.

Special settings in etc/php/php.ini

    upload_max_filesize = 16G
    post_max_size = 16G
    max_input_time 14400
    max_execution_time 14400
    sys_temp_dir = "/media/HDD5000GB/nextcloud_tmp/"
    upload_tmp_dir ="/media/HDD5000GB/nextcloud_tmp/"

Special settings in /etc/httpd/conf/extra/nextcloud.conf

    php_admin_value open_basedir "/media/HDD5000GB/nextcloud_tmp/:
    LimitRequestBody 2147483647
    SSLRenegBufferSize 10486000

Special settings in /usr/share/webapps/nextcloud/.htaccess

<IfModule mod_php7.c>
  php_value upload_max_filesize 16G
  php_value post_max_size 16G
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>

Special settings in /usr/share/webapps/nextcloud/.user.ini

upload_max_filesize=16000M
post_max_size=16400M
memory_limit=512M
mbstring.func_overload=0
always_populate_raw_post_data=-1
default_charset='UTF-8'
output_buffering=0

Output of df -h /tmp/ /media/HDD5000GB/:

tmpfs           999M     0  999M   0% /tmp
/dev/sdb1       4.6T  3.6T  760G  83% /media/HDD5000GB

I have no idea which settings I had forgotten to set correctly… please help me to get those awesome cloud working again for big files.

Do you have a 64-bit php?
php -r 'echo PHP_INT_MAX."\n";'
If the output is 2147483647, it is a 32-bit version which has limits when uploading more than these 2147483647 bytes (2 GiB). Some time ago there was a fix promised for NC 13 but I’m not sure if it was implemented and if not why that is not the case.

gives me

9223372036854775807

So this should not be the reason. The 2GB is a guess, I used files with 1.6 and 2.1GB. Thank you.

You didn’t specify the tmp-folder in your config/config.php:

/**
 * Override where Nextcloud stores temporary files. Useful in situations where
 * the system temporary directory is on a limited space ramdisk or is otherwise
 * restricted, or if external storages which do not support streaming are in
 * use.
 *
 * The Web server user must have write access to this directory.
 */
'tempdirectory' => '/tmp/nextcloudtemp',

I don’t really know what is used as a default, I suppose it should be the system’s default so it should be ok for you.

With the error expected file size, we had a number of things you can check (and you probably went through this list):
https://forum.owncloud.org/viewtopic.php?t=32517

Do you use SELinux or other security modules?