webdav_list_files | 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 containing:
The name of the file.
The path of the file relative to the specified folder.
The date and time when the file was last modified.
The size of the file in bytes.
Returns 'NULL' if an error occurs during the execution of the function.
# 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 = 1, max_seconds = 2, 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.