pulli / nextcloud-webdav-uploader
Upload files to Nextcloud over WebDAV from the command line, with chunked uploads, checksum verification, and skip-if-unchanged support.
Package info
github.com/the-pulli/nextcloud-webdav-uploader
pkg:composer/pulli/nextcloud-webdav-uploader
Fund package maintenance!
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.9||^8.0
- symfony/console: ^7.2||^8.0
- symfony/finder: ^7.2||^8.0
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- laravel/pint: ^1.0
- pestphp/pest: ^4.0
README
A standalone command-line tool for uploading files and folders to Nextcloud over WebDAV. Files above ~4 GiB automatically use Nextcloud's NG chunking API instead of a single PUT. Every upload is checksummed: unchanged files are skipped on a rerun, and every fresh upload is verified against the remote checksum afterwards.
Using Laravel? See laravel-nextcloud-webdav-uploader for an Artisan command built on top of this package's
NextcloudClient.
Features
- Upload single files or whole directories (optionally recursive)
- Automatic chunked uploads for large files, with a progress bar
- SHA1 checksum skip-if-unchanged: rerunning against the same destination only transfers what changed
- Post-upload checksum verification, so a corrupted transfer fails loudly instead of silently
- Optional public share link creation
Installation
You can install the package via composer:
composer require pulli/nextcloud-webdav-uploader
Configuration
The tool reads its Nextcloud credentials from environment variables, either exported directly or via a .env file in the current working directory:
NEXTCLOUD_URL=https://cloud.example.com NEXTCLOUD_USERNAME=jane NEXTCLOUD_PASSWORD=app-password # Optional overrides NEXTCLOUD_CHUNK_THRESHOLD=4294967296 # bytes; default ~4 GiB NEXTCLOUD_CHUNK_SIZE=536870912 # bytes; default 512 MiB NEXTCLOUD_TIMEOUT=300 # seconds
See .env.example.
Usage
# Upload a single file into /Uploads ./nextcloud-webdav-uploader --file=/path/to/file.pdf # Upload into a specific folder (created if missing) ./nextcloud-webdav-uploader Documents/2026 --file=/path/to/file.pdf # Upload a directory (its direct files only) as a subfolder of the target folder ./nextcloud-webdav-uploader Backups --file=/path/to/folder # ...including nested subdirectories, preserving structure ./nextcloud-webdav-uploader Backups --file=/path/to/folder --include-subdirs # Multiple files/folders in one run ./nextcloud-webdav-uploader Backups --file=/path/a --file=/path/b.txt # Create (or reuse) a public share link for the target folder afterwards ./nextcloud-webdav-uploader Shared --file=/path/to/file.pdf --share-dir # ...or for the uploaded file itself (only valid with exactly one file) ./nextcloud-webdav-uploader Shared --file=/path/to/file.pdf --share-file
Rerunning the same command only re-uploads files whose content actually changed — everything else is reported as unchanged, skipped.
Options
| Option | Description |
|---|---|
folder |
Target folder in Nextcloud, relative to the user's files root (default: Uploads) |
--file, -f |
Local file or directory to upload (repeatable) |
--include-subdirs |
Recurse into subdirectories of a --file directory, preserving structure |
--chunk-size |
Override the chunk size in MB for files above the chunking threshold |
--force-chunk-above |
Override the chunking threshold in MB (useful to exercise chunking without a huge test file) |
--share-dir |
Create (or reuse) a public link share for the target folder and print it |
--share-file |
Create (or reuse) a public link share for the uploaded file and print it (exactly one file only) |
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.