#8321·rclone

Improve nextcloud webdav backend by adding chunk upload v2

Author: adipplCreated Jan 20, 2025Updated Sep 25, 2026
LabelsenhancementRemote: WebDAV

What is your current rclone version (output from rclone version)?

rclone v1.70.0-DEV

  • os/version: gentoo 2.17 (64 bit)
  • os/kernel: 6.12.9-gentoo-dist (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.23.4
  • go/linking: dynamic
  • go/tags: none

What problem are you are trying to solve?

Rclone nextcloud webdav backend is very bad at uploading files because of unreliable nextcloud file merging and file locking. Uploading larger files with rclone is very unreliable.

Rclone should have full support for "lockless" file upload to nextcloud which is possible with chunk upload v2 feature. This upload method is described here in nextcloud documentation: https://docs.nextcloud.com/server/latest/developer_manual/client_apis/WebDAV/chunking.html

This allows direct multipart uploads to s3 bucket. (It's faster, better and safer approach to uploading data to nextcloud with s3.) This feature is described here: https://github.com/nextcloud/server/pull/27034

Modified example script uploading files via chunkv2
bash
#!/bin/bash
# Usage: ./upload.sh filename_on_nextcloud

if [ -z "$1" ]
then
  echo "Usage: ./s3-chunk filepath"
exit 1
fi

TMPDIR=tmp-dir-$RANDOM

mkdir $TMPDIR

CHUNKSIZE=100
CHUNKS=10
> $TMPDIR/one.testbin
for i in $(seq 1 $CHUNKS)
do
#CHUNKSIZE=$(( $RANDOM % 10 + 5 ))
dd if=/dev/random of=$TMPDIR/$i.testbin bs=${CHUNKSIZE}M count=1 2>/dev/null
cat $TMPDIR/$i.testbin >> $TMPDIR/one.testbin
done

ls -l $TMPDIR/*.testbin

SERVER=https://nextcloud.example
USER=username
PASS=password
FILENAME=$1
timestamp=$(date +%s)

echo "=> Cleanup existing file"
curl -X DELETE -u $USER:$PASS "$SERVER/remote.php/dav/files/$USER/$FILENAME"



DESTINATION="$SERVER/remote.php/dav/files/$USER/$FILENAME"

echo "Uploading to $USER:$PASS $SERVER/remote.php/dav/uploads/$USER/$timestamp"
echo "=> MKCOL"
curl -v -X MKCOL -u $USER:$PASS $SERVER/remote.php/dav/uploads/$USER/$timestamp \
-H "Destination: $DESTINATION"

echo "=> PUT"
for i in $(seq 1 $CHUNKS | shuf)
do
echo "- PART $i"
(curl -X PUT -u $USER:$PASS $SERVER/remote.php/dav/uploads/$USER/$timestamp/$i -T $TMPDIR/$i.testbin -H "X-S3-Multipart-Destination: files/$USER/$FILENAME" -H "Destination: $DESTINATION"; echo " - DONE $i") &
done

wait

# exit 1;

echo "=> MOVE"
#curl -X MOVE -u $USER:$PASS --header "Destination:$SERVER/remote.php/dav/files/$USER/$FILENAME" $SERVER/remote.php/dav/uploads/$USER/$timestamp/.file -H "Destination: $DESTINATION"
curl -X MOVE -u $USER:$PASS $SERVER/remote.php/dav/uploads/$USER/$timestamp/.file -H "Destination: $DESTINATION"

curl -u $USER:$PASS $SERVER/remote.php/dav/files/$USER/$FILENAME > $TMPDIR/compare.testbin

md5sum $TMPDIR/one.testbin
md5sum $TMPDIR/compare.testbin

ls -l $TMPDIR/*.testbin

rm $TMPDIR/*.testbin
rm -rf $TMPDIR

How do you think rclone should be changed to solve that?

I have a working fork with this feature implemented. I would like you to review it, suggest changes and merge it into the project. https://github.com/adippl/rclone-webdav-nextcloud-chunkv2-upload/tree/webdav-nextcloud-chunkv2-upload

I've added this feature behind non default config option nextcloud_chunk_v2 I've tested it on file uploads to nextcloud-29 with filesystem backend and nextcloud-30 with s3 backend and in both cases file upload is successful. I've tested this upload method up to 40GiB file uploaded via 10MiB and 100MiB chunks. In both cases upload complete fine without any 423 or 404 errors like in current rclone implementation. With chunkv2 upload usually finishes with single MOVE request. (I've only noticed lags when my self hosted s3 server was under heavy load)

Chunk upload v2 feature was created to be backwards compatible with chunkv1 mechanism. From what I've gathered chunkv2 upload require redis to work correctly. If redis is not available, nextcloud should fall back to chunkv1 mechanism. I think, chunkv2 could be enabled by default after some more testing.

I'm not 100% sure if X-S3-Multipart-Destination header used in example is strictly necessary. In my tests multipart upload worked without it. It doesn't affect uploads to filesystem backed nextcloud.

How to use GitHub

  • Please use the reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.