Tmp directory permissions after restore of nextcloudpi

Hello everybody!

I switched nextcloudpi to buster by installing the new image to the SD-card on my Pi3 and restoring nextcloudpi afterwards. (Failed a couple of times since I thought that “include data” would not be necessary to restore a working nextcloud instance without any photos etc. but only the database)

Anyway, the restore worked except that I cannot upload any files anymore. The error message I get is:

{"reqId":"XXaZ57R8Z3Nr9YK1DVDMDwAAAMc","level":3,"time":"2019-09-09T18:28:55+00:00","remoteAddr":"","user":"sven","app":"PHP","method":"PUT","url":"/remote.php/dav/uploads/sven/9f4f3056829d09e0e00810594ccd03a1/0000000000000000-0000000010239999","message":"**fread(): Unable to create temporary file, Check permissions in temporary files directory**. at /var/www/nextcloud/3rdparty/icewind/streams/src/Wrapper.php#91","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.7.2","version":"","id":"5d7699e87df57"}

php.ini sets the tmp-folder to:

I ran the “fix permissions” in ncp-web already. Checked the permissions on the folder and they seem to be ok as well:

drwxr-xr-x 1 www-data www-data

What else could I check?


Seems like I am not the only one: Cannot upload files, error "expected filesize 5160954 got 8192" appears

Does nobody have an idea what else to check and why this issue comes up after the restore in the first place?

I’ve restored multple times without doing much more than checking permissions, this issue looks loike somthing php related

I have the same problem, after restoring to the same hardware.

I’m having the same issue. Also I cannot access the App-store from within Nextcloud.

mmm maybe try changing /media/USBdrive, which should be a symlink for the real path in config.php

1 Like

my tmp was pointing to /var/www/nextcloud/tmp, now I moved it to /media/etc/etc and it seem to work

Hey, I’ve got the same issue.
Could you explane to me, what "changing /media/USBdrive " means? I’ve got access to the Pi by SSH, but I’m worried to break something.

Best wishes!

I ran the “fix-permissions” without an error. I don’t know if the following output helps

pi@nextcloudpi:/media $ ls -la
total 24
drwxr-xr-x  3 root root 4096 Oct 13 04:00 .
drwxr-xr-x 21 root root 4096 Jul 10 01:21 ..
drwxr-xr-x  1 root root  110 Aug  7 14:09 myCloudDrive
lrwxrwxrwx  1 root root   19 Oct 13 04:00 USBdrive -> /media/myCloudDrive
    > pi@nextcloudpi:/media/USBdrive $ ls -la
    > total 20
    > drwxr-xr-x 1 root     root      110 Aug  7 14:09 .
    > drwxr-xr-x 3 root     root     4096 Oct 13 04:00 ..
    > drwxrwx--- 1 www-data www-data  254 Oct 10 17:11 ncdata
    > drwxr-x--- 1 www-data www-data  224 Aug  7 14:09 ncdata-08-07-19
    > drwxr-xr-x 1 mysql    mysql     318 Sep 24 20:24 ncdatabase
    > drwxr-xr-x 1 root     root      228 Oct 10 15:50 ncp-backups
    > drwxr-xr-x 1 root     root     1390 Jul 29 12:17 ncp-snapshots

Simply open your config.php file, locate the path of your tmp rename it. My issue was that my hard drive actual link is not /media/USBDrive but /media/alphanumericstuff , so I changed that to the secondo one. You can check it by showing the directories in /media

Thanks a lot for the reply!
my tempdirectory points to ‘/media/USBdrive/ncdata/tmp’ (according to ncp-web).

Output for ‘/media/USBdrive/ncdata/tmp’:
drwxr-xr-x 1 www-data www-data 0 Oct 10 17:11 tmp

That seems correct? Should I change the path of tempdirectory to ‘/media/myCloudDrive/ncdata/tmp’, so not use the symbolic link? Where is the config.php located?

Thanks in advance! And sorry for asking Noob-Questions :slight_smile:

right now I don’t have access to my server because it has problems so I cannot check, but if i remember correctly it should be somewhere around /var/www/nextcloud/ or so. you can always use $ find . -iname config.php to locate it, where the dot means that the initial directory is the actual one, so you could put / to look everywhere.

Thanks a lot! I forgot the -iname option last time :sweat_smile:
It’s " ./var/www/nextcloud/config/config.php" in my case.
I will test it as soon as possible and report afterwards!

I came to this comment from here, however my temp directory is already correctly set to my external HDD. Nonetheless, I’m still getting the error Sabre\DAV\Exception\BadRequest: expected filesize 218023 got 8192.

Any clue on the subject?

My php max upload size is 10GB.

are you sure that your link to the external hdd is correct?

Very confident as the HDD is correctly mounted at each reboot of the host (RaspberryPi 3 B+) and I can even browse it in Nextcloud using the pre-existent External Storage plugin.

My fstab:

/dev/sda8 /mnt/ugreen auto defaults 0 0

The HDD NCP folder permissions (personal folders removed for the sake of it):

.# ls -la /mnt/ugreen/
drwxr-x— 11 www-data www-data 4096 Oct 13 13:19 ncp
-rw-r----- 1 www-data www-data 131020 Oct 12 15:56 nextcloud.log

.# ls -la /mnt/ugreen/ncp
total 284
drwxr-xr-x 3 www-data www-data 4096 Oct 12 14:09 appdata_oc5zp34tvs4m
drwxr-xr-x 8 www-data www-data 4096 Oct 12 13:49 appdata_octf5k83gwfo
drwxr-xr-x 9 www-data www-data 4096 Oct 13 13:10 appdata_ocvh9tig3kts
drwxr-xr-x 2 www-data www-data 4096 Oct 11 08:04 files_external
-rw-r–r-- 1 www-data www-data 324 Oct 12 15:58 .htaccess
-rw-r–r-- 1 www-data www-data 0 Oct 12 15:58 index.html
drwxr-xr-x 5 www-data www-data 4096 Oct 13 13:21 Maxiride
drwxr-xr-x 6 www-data www-data 4096 Oct 12 16:53 ncp
drwxr-xr-x 4 www-data www-data 4096 Oct 11 08:05 news
-rw-r----- 1 www-data www-data 235313 Oct 13 14:35 nextcloud.log
-rw-r–r-- 1 www-data www-data 0 Oct 12 15:58 .ocdata
drwxr-xr-x 3 www-data www-data 4096 Oct 11 08:00 .opcache
drwxr-xr-x 2 www-data www-data 4096 Oct 12 15:04 tmp

cat /var/www/nextcloud/config/config.php | grep temp
‘tempdirectory’ => ‘/mnt/ugreen/ncp/tmp’,

cat /var/www/nextcloud/config/config.php | grep data
‘datadirectory’ => ‘/mnt/ugreen/ncp’,


in my case the hdd was mounted correctly but the symbolic link in the tmp definition caused the error. is ugreen is not the symbolic link of the drive then it is correct and I don’t know how to help you

No it isn’t a symbolic link.
Thanks anyway :slight_smile:

Unfortunately the symbolic link wasn’t the problem. The error remains. Any hint or progress on the subject?

Some things to consider…

I too was having “BadRequest: expected filesize” errors. I made a number of changes relating to upload timeouts and the problem has reduced significantly.

Add this line to the “Directory” section of the conf file that I use to load the apache config for the Nextcloud server.


LimitRequestBody 0

References from -

Define the temporary files location in this file:

sys_temp_dir = “/myvolume/nextcloud_tmp”

Note that I also have the temp files location specified in my Nextcloud config file to point to the same location also:

‘tempdirectory’ => ‘/myvolume/nextcloud_tmp’,

References from -


to the Nextcloud config.php file, I made these changes:

added this to the redis section:
‘timeout’ => 0,

References from -