I need a command-line utility that can do WebDAV upload (HTTP PUT).
I need a command-line utility that can do WebDAV upload (HTTP PUT).
The most commonly used command line HTTP utility seems to be cURL, which will do PUT with its -T option. You would need to understand quite a bit of the WebDAV protocol to do more than upload with it, though.
If you need to upload the entire directory instead of one file over WebDAV, you can use the following approach.
Imagine you have the following local folder you're going to upload over WebDAV.
local_folder_to_upload
│ test.txt
│ test1.txt
│
└───nested_folder1
│ │ file1.txt
│ │ file2.txt
│ │
│ └───nested_folder2
│ │ file11.txt
│ │ file12.txt
1.First you need to create nested directories from your local folder (if you have them) on a server. Since WebDAV doesn't support recursive upload, you have to do this in separate step (if you were to use ftp - you would add --ftp-create-dirs flag to do this). To create those folders over WebDAV you need to use MKCOL method.
curl -X MKCOL 'http://your.server/uploads/nested_folder1' --user 'name:pwd'
curl -X MKCOL 'http://your.server/uploads/nested_folder1/nested_folder2' --user 'name:pwd'
Please note that you can't create them in one request according to the spec.
if a request to create collection /a/b/c/d/ is made, and /a/b/c/ does not exist, the request must fail.
2.Second you can utilize output of find shell command to upload it to your server using curl.
cd local_folder_to_upload && find . -exec curl -T {} 'http://your.server/uploads/{}' --user 'name:pwd' \;
Code above loop over all your files inside given directory (using find) and add the output (file name with relative path) to the placeholder {} in the url of your webserver. So it makes multiple requests (one per each file), and since all nested folders were created in advance - those requests shouldn't fail.
Hope it's helpful to someone.
this overview contains a thourough list of webdav server and clients.
I'd opt for cadaver or, if my needs were very specific, a python script using the PyWebDAV library.
To do WebDAV recursive upload of an arbitrary directory structure (files inside folders inside folders, etc.), the tool Rclone worked for me.
Based on this answer on SuperUser, I was able to recursively copy a directory by doing the following:
rclone config create my-remote webdav \
url https://my-webdav-server/my-dir/ \
vendor other \
user 'username'
rclone config password pass 'mypasswd'
rclone copy /home/me/mydir my-remote:
Rclone offers a number of other modes of dealing with files, including sync, which brings the remote in line with the local copy by removing remote files not present locally (in addition to copying local files across that do not exist remotely). See the subcommands of Rclone for more information.
Teleric Fiddler has a "compose" tab where you can create your own customized WebDAV request. E.g. PROPFIND and OPTIONS etc.