I recently had the need to upload a bunch of PDF files from a linux server to my Nextcloud instance. Nextcloud doesn't currently have a headless linux client, but WebDAV is available by default.

Uploading a single file is as simple as:

curl -T local-filename.pdf -u 'username:password' "https://nextcloud.mydomain.tld/remote.php/dav/files/username/remote_filename.pdf

Note that the path above needs to include the username used to authenticate with. For example, I'd use something like /remote.php/dav/files/justyn/remote_filename.pdf. After /justyn/ is the root of my main directory in Nextcloud.

Bonus example: Uploading all of the PDF files in a directory

This is roughly what I used to upload all of my PDF files in my scanner incoming directory. I did not want to include files that end in .tif.pdf because those are single pages, where as the file ending in just .pdf is all of the pages combined and OCR'd.

find . -type f -name \*.pdf -a ! -name \*.tif.pdf | while read x;do filename=$(basename $x); echo $filename;curl -T $x -u 'scannerusername:password' "https://nextcloud.mydomain.tld/remote.php/dav/files/scannerusername/ScansnapInbox/$filename";done

References