Error with chunked file uploads through Windows Client

Background info:

  • Nextcloud server 20.0.11 running on Ubuntu 20.04.2 LTS using Apache2
  • Nextcloud client 3.3.3.20210903 running on Windows 21H1 build 19043.1165

I can upload files larger than 10 MB or so through the web interface but they do not sync through the Windows client. Files smaller than 10 MB sync correctly through the Windows client. I have checked the php.ini config and the limits are much more than 10 MB. I have checked permissions on the data directory and www-data is the owner of it and has permissions (and its subdirectories).

The error from my Windows client:

Server replied "403 Forbidden" to MKCOL https://[server ip]/nextcloud/remote.php/dav/uploads/user/164584880" (Could not create directory //164584880)

I recently reinstalled NextCloud after reconfiguring my server data partitions. Previously uploads larger than 10 MB worked on my NextCloud setup when using the Windows client.

What could be the issue here?

well I haven’t found a solution yet but I believe it’s related to mod_dav, WebDav, or SabreDav. not sure what any of those words mean yet but I think I’m headed in the right direction. the troubleshooting section on dav stuff hasn’t helped unfortunately

status update, turns out NextCloud uses SabreDav as its DAV solution (wiki article). I think it’s already installed on my system. I made sure the cache and temp folders had the right permissions and I think that fixed some things but now it’s saying a temporary file is not readable in nextcloud.log:

unable to rename, source directory is not writable : nextcloud-storage/cache/intcreator/uploads/2043559751

I can confirm that nextcloud-storage/cache/intcreator/uploads/ exists and has the correct permissions (at least read and execute up to nextcloud-storage and rwx for www-data for everything under cache. for some reason NextCloud says it doesn’t have access to a file or folder that it supposedly created. after this error I can’t see anything in the uploads folder

you can try the permissions with running a command as the webserver user. E.g. creating an empty file:

sudo -u www-data touch /path/to/folder/test.txt

Permissions can be tricky because it depends on parent folders as well, and if you have problems with the drive, it can be mounted read-only.

good suggestion, I tried that command and it created the file no problem. Nextcloud is running on a different partition than the OS but I can create files no problem so it’s not mounted read only. the cache folder is on the same partition that NextCloud is installed on. also everything NextCloud works except for syncing files over 10 mb.

I did track down the exact lines of code that are coming up over and over in my error log:

mkdir($cacheDir, 0770, true);
mkdir($cacheDir . '/uploads', 0770, true);

here’s a GitHub link for context. for some reason the PHP script is unable to do what I’m doing on the command line…

Sounds a bit like the open_basedir settings don’t allow it, or some other firewall/security mechanism that limits to scripts to certain paths…

ok, I made a test file in PHP to see if it could mimic the behavior Nextcloud is failing at:

<?php

echo get_current_user();

$cacheDir = './nextcloud-cache/test';

if (!file_exists($cacheDir)) {
    mkdir($cacheDir, 0770, true);
    mkdir($cacheDir . '/uploads', 0770, true);
}

the weird thing is this file actually works! it created the test directory as well as the uploads subdirectory with the correct permissions and the user www-data (which I also verified was the user running PHP). because of this I want to rule out Apache config issues and possibly firewall issues. I put the PHP file in my www directory right next to the nextcloud directory, I’m not sure how much closer I can get to Nextcloud without interfering with it.

I’m also getting a related error at this line in the SabreDav library:

$result = $node->put($data);

GitHub link for context

well I’m getting this error in the browser too now.

image

I swear I could upload large files in the browser before, but now I can’t?

I think I may have fixed it. I decided to go with the most easily accessible location for the cache folder, /tmp/nextcloud-cache/ and it worked for at least one test case. I tried for days with two other locations going over permissions again and again and nothing ever worked. hopefully putting the cache files there isn’t an issue.

Edit: yes this fixed it. just to be clear this is the line I changed in /var/www/nextcloud/config/config.php

 'cache_path' => '/tmp/nextcloud-cache/',