Curl is a command line tool for doing all sorts of URL manipulations and transfers, but this particular post will focus on how to use curl for managing (read/ delete/ rename/ upload) files on Webdav Server. While the second part of the post will cover implementation of Two Factor Authentication for the same. I'll assume that you know how to execute 'curl' command using terminal and invoke 'curl --help' or 'curl --manual' to get basic information about it.
Assume we have following Data:
Webdav URL: https://example.com/webdav
Username: user
Password: pass
Note: It is recommended to read article completely (both management and curl options) before implementation.
This document provides a quick overview of the WebDAV operations supported in Nextcloud, to keep things readable it won’t go into many details for each operation, further information for each operation can be found in the corresponding rfc where applicable
WebDAV is an extension to HTTP/1.1, and it is defined in RFC 4918. It extends the HTTP primitives in order to allow for file manipulation and colaborative authoring.
Some of these primitives include ( from Wikipedia )
COPY copy a resource from one URI to another
LOCK put a lock on a resource. WebDAV supports both shared and exclusive locks.
MKCOL create collections (a.k.a. a directory)
MOVE move a resource from one URI to another
PROPFIND retrieve properties, stored as XML, from a web resource. It is also overloaded to allow one to retrieve the collection structure (also known as directory hierarchy) of a remote system.
PROPPATCH change and delete multiple properties on a resource in a single atomic act
UNLOCK remove a lock from a resource
How To Set Up WebDAV With Lighttpd On Debian Etch