webdav_download_file | R Documentation |
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.
webdav_download_file(
base_url,
file_path,
destination_path = ".",
username = Sys.getenv("WEBDAV_USERNAME"),
password = Sys.getenv("WEBDAV_PASSWORD"),
verbose = FALSE
)
base_url |
The base URL of the WebDAV server (e.g., "https://example.com/remote.php/dav/files/"). |
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. |
Logical value indicating whether the file was downloaded successfully.
# Example usage with a public WebDAV server.
library(magrittr)
library(httr2)
test_server <- "https://www.webdavserver.com/" %>%
request() %>%
req_retry(max_tries = 1, max_seconds = 2, 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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.