The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
This overview introduces the webdav
R package, which
provides an interface for managing files on WebDAV-compliant servers,
enabling file operations such as uploading, downloading, copying,
moving, and deleting resources.
This function creates a basic authenticated WebDAV request for the given resource path on a WebDAV server. It sets up authentication using the provided username and password and returns a request object.
Parameters:
base_url
: Base URL of the WebDAV server (e.g.,
https://drive.expresso.pe.gov.br
).username
: Username for authentication.password
: Password for authentication.verbose
: Whether to print debug information (default is
FALSE
).Example:
# Example usage with a public WebDAV server.
# Visit test_server$url link to view the results of the operation.
library(magrittr)
library(httr2)
test_server <- "https://www.webdavserver.com/" %>%
request() %>%
req_retry(max_tries = 3, max_seconds = 4, backoff = ~ 1) %>%
req_perform() %>%
try(silent = TRUE)
# Create a request
if (class(test_server) != "try-error")
req <- webdav_create_request(base_url = test_server$url, verbose = TRUE)
This function copies a file or directory from one path to another on a WebDAV server.
Parameters:
base_url
: Base URL of the WebDAV server.from_path
: The source file path to copy.to_path
: The destination path where the file will be
copied.username
: Username for authentication.password
: Password for authentication.Example:
# Example usage with a public WebDAV server.
# Visit test_server$url link to view the results of the operation.
library(magrittr)
library(httr2)
test_server <- "https://www.webdavserver.com/" %>%
request() %>%
req_retry(max_tries = 3, max_seconds = 4, backoff = ~ 1) %>%
req_perform() %>%
try(silent = TRUE)
# Copy a file from one path to another
if (class(test_server) != "try-error")
webdav_copy_file(base_url = test_server$url,
from_path = "Project.pdf",
to_path = "New_Project.pdf",
verbose = TRUE)
This function creates a new directory (or collection) on the WebDAV server using the MKCOL method.
Parameters:
base_url
: Base URL of the WebDAV server.folder_path
: Path to the directory to be created.username
: Username for authentication.password
: Password for authentication.Example:
# Example usage with a public WebDAV server.
# Visit test_server$url link to view the results of the operation.
library(magrittr)
library(httr2)
test_server <- "https://www.webdavserver.com/" %>%
request() %>%
req_retry(max_tries = 3, max_seconds = 4, backoff = ~ 1) %>%
req_perform() %>%
try(silent = TRUE)
# Create a directory on the WebDAV server
if (class(test_server) != "try-error")
webdav_create_directory(
base_url = test_server$url,
folder_path = "Test_Folder",
verbose = TRUE)
This function deletes a file or directory from the WebDAV server using the DELETE method.
Parameters: 1. base_url
: Base URL of
the WebDAV server. 1. resource_path
: The path to the file
or directory to delete. 1. username
: Username for
authentication. 1. password
: Password for
authentication.
Example:
# Example usage with a public WebDAV server.
# Visit test_server$url link to view the results of the operation.
library(magrittr)
library(httr2)
test_server <- "https://www.webdavserver.com/" %>%
request() %>%
req_retry(max_tries = 3, max_seconds = 4, backoff = ~ 1) %>%
req_perform() %>%
try(silent = TRUE)
# Delete a file or directory
if (class(test_server) != "try-error")
webdav_delete_resource(base_url = test_server$url,
resource_path = "Notes.txt",
verbose = TRUE)
This function lists the files within a directory on the WebDAV server using the PROPFIND method.
Parameters:
base_url
: Base URL of the WebDAV server.folder_path
: Path to the folder to list files.username
: Username for authentication.password
: Password for authentication.depth
: Depth of the PROPFIND request (default is
1
).Example:
# Example usage with a public WebDAV server.
# Visit test_server$url link to view the results of the operation.
library(magrittr)
library(httr2)
test_server <- "https://www.webdavserver.com/" %>%
request() %>%
req_retry(max_tries = 3, max_seconds = 4, backoff = ~ 1) %>%
req_perform() %>%
try(silent = TRUE)
# List files in a directory
if (class(test_server) != "try-error")
webdav_list_files(
base_url = test_server$url,
folder_path = "Sales/",
verbose = TRUE)
webdav_upload_file(
base_url,
local_path,
server_path,
username,
password,
timeout = 300,
verbose = FALSE
)
This function uploads a local file to the WebDAV server.
Parameters:
base_url
: Base URL of the WebDAV server.local_path
: Local path to the file.server_path
: Path on the WebDAV server where the file
will be uploaded.username
: Username for authentication.password
: Password for authentication.timeout
: Time limit for the upload operation (default
is 300 seconds).Example:
# Example usage with a public WebDAV server.
# Visit test_server$url link to view the results of the operation.
library(magrittr)
library(httr2)
test_server <- "https://www.webdavserver.com/" %>%
request() %>%
req_retry(max_tries = 3, max_seconds = 4, backoff = ~ 1) %>%
req_perform() %>%
try(silent = TRUE)
# Upload a file
file_test <- tempfile(pattern = "teste_", fileext = ".txt")
cat("Text file content", file = file_test)
if (class(test_server) != "try-error")
webdav_upload_file(base_url = test_server$url, local_path = file_test, verbose = TRUE)
This function downloads a file from the WebDAV server and saves it to a local directory. It validates the provided parameters, handles errors, and optionally prints detailed logs if requested.
Parameters:
base_url
: The base URL of the WebDAV server.file_path
: The path of the file on the WebDAV server to
download (relative to the ‘base_url’).destination_path
: The local directory where the
downloaded file will be saved. Defaults to the current directory.username
: The username for WebDAV authentication.
Defaults to the “WEBDAV_USERNAME” environment variable.password
: The password for WebDAV authentication.
Defaults to the “WEBDAV_PASSWORD” environment variable.verbose
: Logical. If TRUE, prints detailed messages
during the download process.Example:
# Example usage with a public WebDAV server.
library(magrittr)
library(httr2)
test_server <- "https://www.webdavserver.com/" %>%
request() %>%
req_retry(max_tries = 3, max_seconds = 4, backoff = ~ 1) %>%
req_perform()
# Download a file from the WebDAV server
if (class(test_server) != "try-error")
webdav_download_file(base_url = test_server$url,
file_path = "Project.pdf",
destination_path = tempdir(),
verbose = TRUE)
# Visit test_server$url to view the results of the operation.
The webdav
R package provides a
interface for managing files and directories on WebDAV-enabled servers.
With basic file management (uploading, downloading, deleting, copying),
directory management, and resource locking, the package simplifies
interactions with platforms like OwnCloud,
NextCloud, and other WebDAV-compliant systems.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.