WebDAV (Web Distributed Authoring and Versioning) is an extension of the HTTP protocol that allows users to collaboratively edit and manage files stored on remote web servers. It provides a framework for users to create, delete, copy, move, and download files.
Some platforms that implement WebDAV are:
Install the released version from CRAN:
install.packages("webdav")Or the development version from GitHub:
# install.packages("remotes")
remotes::install_github("StrategicProjects/webdav")| Function | WebDAV method | Description |
|---|---|---|
webdav_create_request() |
— | Build an authenticated httr2 request for the
server |
webdav_list_files() |
PROPFIND | List files and folders as a tibble |
webdav_upload_file() |
PUT | Upload a local file (streamed from disk) |
webdav_download_file() |
GET | Download a file (streamed to disk) |
webdav_create_directory() |
MKCOL | Create a collection (directory) |
webdav_copy_file() |
COPY | Copy a resource |
webdav_move_file() |
MOVE | Move or rename a resource |
webdav_delete_resource() |
DELETE | Delete a file or directory |
Credentials default to the WEBDAV_USERNAME and
WEBDAV_PASSWORD environment variables (see
vignette("env_variables")):
library(webdav)
base_url <- "https://cloud.example.com/remote.php/dav/files/user"
# List what's there
webdav_list_files(base_url, folder_path = "Documents")
# Upload, rename, download, clean up
webdav_upload_file(base_url, local_path = "report.pdf", server_path = "Documents")
webdav_move_file(base_url,
from_path = "Documents/report.pdf",
to_path = "Documents/report-2026.pdf")
webdav_download_file(base_url,
file_path = "Documents/report-2026.pdf",
destination_path = tempdir())
webdav_delete_resource(base_url, resource_path = "Documents/report-2026.pdf")Invalid arguments raise an error; network or server failures issue a
warning and return FALSE (NULL for
webdav_list_files()), so scripts can test the return value
instead of wrapping calls in tryCatch().