Cannot upload files, error "expected filesize 5160954 got 8192" appears

Nextcloud version : 16.0.4
Operating system and version : raspbian 9
Apache or nginx version :
PHP version : 7.3

The issue you are facing:

I cannot upload files and “expected filesize 5160954 got 8192” error appears, the second number is always the same

Is this the first time you’ve seen this error? : yes

Steps to replicate it:

  1. be as unlucky as I am

The interesting parts of the Nextcloud log:

[webdav] Fatal: Sabre\DAV\Exception\BadRequest: expected filesize 5160954 got 8192 at <<closure>>

0. /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php line 156
   OCA\DAV\Connector\Sabre\File->put(null)
1. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1096
   OCA\DAV\Connector\Sabre\Directory->createFile("01PEEQW_Robotics_Kinematics.pdf", null)
2. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 525
   Sabre\DAV\Server->createFile("01PEEQW_Robotics_Kinematics.pdf", null, null)
3. <<closure>>
   Sabre\DAV\CorePlugin->httpPut(Sabre\HTTP\Reque ... "}, Sabre\HTTP\Response {})
4. /var/www/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php line 105
   undefinedundefinedcall_user_func_array([Sabre\DAV\CorePlugin {},"httpPut"], [Sabre\HTTP\Requ ... }])
5. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 479
   Sabre\Event\EventEmitter->emit("method:PUT", [Sabre\HTTP\Requ ... }])
6. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 254
   Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Reque ... "}, Sabre\HTTP\Response {})
7. /var/www/nextcloud/apps/dav/appinfo/v1/webdav.php line 80
   Sabre\DAV\Server->exec()
8. /var/www/nextcloud/remote.php line 163
   undefinedundefinedrequire_once("/var/www/nextcl ... p")

PUT /remote.php/webdav/01PEEQW_Robotics_Kinematics.pdf
from foo.bar by at user 2019-09-10T10:17:54+00:00




[PHP] Error: fread(): Unable to create temporary file, Check permissions in temporary files directory. at /var/www/nextcloud/3rdparty/icewind/streams/src/Wrapper.php#91

PUT /remote.php/webdav/01PEEQW_Robotics_Kinematics.pdf
from 85.51.116.115 by user at 2019-09-10T10:17:54+00:00

The output of my config.php:
$CONFIG = array (
‘passwordsalt’ => ‘…’,
‘secret’ => ‘…’,
‘trusted_domains’ =>
array (
0 => ‘localhost’,
7 => ‘nextcloudpi’,
8 => ‘nextcloudpi.lan’,
),
‘datadirectory’ => ‘/media/USBdriva/ncdata’,
‘dbtype’ => ‘mysql’,
‘version’ => ‘16.0.4.0’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘mysql.utf8mb4’ => true,
‘installed’ => true,
‘mail_smtpmode’ => ‘sendmail’,
‘mail_smtpauthtype’ => ‘LOGIN’,
‘mail_from_address’ => ‘admin’,
‘mail_domain’ => ‘ownyourbits.com’,
‘overwriteprotocol’ => ‘https’,
‘maintenance’ => false,
‘theme’ => ‘’,
‘loglevel’ => ‘2’,
‘log_type’ => ‘file’,
‘memcache.local’ => ‘\OC\Memcache\Redis’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ =>
array (
‘host’ => ‘/var/run/redis/redis.sock’,
‘port’ => 0,
‘timeout’ => 0.0,
),
‘twofactor_enforced’ => ‘false’,
‘twofactor_enforced_groups’ =>
array (
),
‘twofactor_enforced_excluded_groups’ =>
array (
),
‘jpeg_quality’ => ‘60’,
‘htaccess.RewriteBase’ => ‘/’,
);

The output of your Apache error log:

[Tue Sep 10 00:00:07.855874 2019] [ssl:warn] [pid 16643:tid 1996157456] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name

[Tue Sep 10 00:00:07.869943 2019] [mpm_event:notice] [pid 16643:tid 1996157456] AH00489: Apache/2.4.38 (Raspbian) OpenSSL/1.1.1c configured -- resuming normal operations

[Tue Sep 10 00:00:07.870058 2019] [core:notice] [pid 16643:tid 1996157456] AH00094: Command line: '/usr/sbin/apache2'

[Tue Sep 10 09:33:23.327648 2019] [mpm_event:notice] [pid 16643:tid 1996157456] AH00491: caught SIGTERM, shutting down

[Tue Sep 10 09:33:23.642852 2019] [ssl:warn] [pid 9235:tid 1995899408] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name

[Tue Sep 10 09:33:23.719361 2019] [ssl:warn] [pid 9236:tid 1995899408] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name

[Tue Sep 10 09:33:23.730832 2019] [mpm_event:notice] [pid 9236:tid 1995899408] AH00489: Apache/2.4.38 (Raspbian) OpenSSL/1.1.1c configured -- resuming normal operations

[Tue Sep 10 09:33:23.731081 2019] [core:notice] [pid 9236:tid 1995899408] AH00094: Command line: '/usr/sbin/apache2'


but trying to upload a file and failing doesn’t seem to create any error in this log.
Also, staring again from a clean installation of 15.0.x doesn’t give me any problem. I have to mention that I have a preexisting ncp instance that I restored after a machine failure. The data are always in the same external disk.
I have restored it multiple times, because I tinker way too much

I have the exact same issue: Tmp directory permissions after restore of nextcloudpi

I’ll follow yours too

I can confirm that issue.
I didn’t change anything, I noticed it because my synchronization stopped working

It seems like a quite spread issue then. Right now I don’t have tim to find a solution myself, but it’s been days since a last could sync my calendar and contacts, maybe I’m going back to nc15 for now

solved with this

Is this problem solved automatically with v1.16.7 (2019-09-11) Increased modsecurity bodynofileslimit so larger files can be synced (#993)? Or is this something else oO

it is not about filesize, it’s about wrong tmp directory link

Where / how to fix?

@DystopianLphant fixed it by modifying the tmpdirectory-path in config.php (see here). But it’s not working in my case unfortunately.

I found a solution, which is working on two Raspberry Pis. Use it with caution, I’m just a beginner on this topic.

Procedure

  1. Locate config.php

cd /var/www/nextcloud/config

  1. Edit config.php

nano config.php

  1. Change line for tempdirectory

‘tempdirectory‘ => ‘/media/USBdrive/ncdata/tmp’
(example)

to

‘tempdirectory‘ => ‘/var/www/nextcloud/data/tmp’

The new folder is located on the SD-card and should have following rights

drwxr-xr-x 2 www-data www-data

  1. Save and Exit by Ctrl+S and Ctrl+X

  2. Reboot the server

  3. Test it by transferring a larger file (should work now)

  4. Undo the changes in config.php and reboot again (now the temp directory should be located on the USB drive again and transferring should work)

Best wishes!

EDIT:
Also check /etc/php/7.3/fpm/php.ini as mentioned from @OliverV below.

6 Likes

So the initially set is not wrong. It is just not used correctly. And by setting and resetting it is then used correctly? Do I understand this in the right manner? But that also looks like a bug where a developer should take care of it.

Yes, it’s like a reset of the temp folder. I think it is a bug and a developer could have a look.
It seems like a problem occurring on the Raspberry Pi. So it may be connected to having the temp folder located on an external USB drive, but I’m not a web developer.

Does not work for me :frowning: I’m desperate with this problem

For me downgrading to v15 solved, temporarily, the issue. In the meanwhile you could do so

I had the same problem on my NextcloudPi on Odroid HC2. The solution of @malbreitenbach solved the problem in my case.

1 Like

I tried again and even if the tmp path is on the SD card I get the error message (so test step 6). Does anyone have another idea?

Interestingly, I don’t have the problem when I upload using the FlowUpload app. Now I’m completely at a loss. Can someone use this knowledge to draw a conclusion about the problem?

Sad to hear,
for me the problem appeared again, because while an update
/var/www/nextcloud/data/tmp
was deleted. I fixed it by recreating the folder with correct rights. I hope some developer will have a look into this. Unfortunatly I don’t know if it’s Nextcloud or NextcloudPi related.
Good luck!

Edit: Merry Christmas! :slight_smile:

3 Likes

Also check
/etc/php/7.3/fpm/php.ini

In some instances this line:

; Defaults to the system default (see sys_get_temp_dir)
sys_temp_dir = /var/www/nextcloud/data/tmp

Needs Edit to point to /path/toyour/ncdata/tmp
commenting out the line works too.

as

; Defaults to the system default (see sys_get_temp_dir)
;sys_temp_dir = “/tmp”

seems to be default

4 Likes