webdav_list_files {webdav} | R Documentation |
This function lists the files in a specific folder on the WebDAV server. If no folder path is provided, it lists files from the root directory. The function validates the provided parameters and handles errors during the process.
webdav_list_files(
base_url,
folder_path = NULL,
username = Sys.getenv("WEBDAV_USERNAME"),
password = Sys.getenv("WEBDAV_PASSWORD"),
depth = 1,
verbose = FALSE
)
base_url |
The base URL of the WebDAV server. |
folder_path |
The path inside WebDAV where the files are located. If not provided or empty, the root folder will be listed. |
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. |
depth |
The depth of the PROPFIND request (default is 1). |
verbose |
Logical value indicating whether to print detailed debug messages. When TRUE, the function outputs additional information about its progress and actions. |
A tibble with the file names and paths relative to the folder, or NULL if an error occurs.
# 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)