Helper Function: Download Nextcloud Files from a Directory
Source:R/influxdb_ultimate.R
download_nextcloud_files.Rd
Helper Function: Download Nextcloud Files from a Directory
Arguments
- dir_cloud
directory on Nextcloud
- dir_local
directory on local computer. If not existing it will be created
- file_pattern
file pattern to be used as download filter (default: "Project\.xls$")
Value
downloads all files from cloud into local folder fullfilling file_pattern
and returns the file
, i.e. filename
Examples
if (FALSE) {
#1 Open RStudio and run usethis::edit_r_environ()
#2 In the opened window add the required environment variables
### NEXTCLOUD_URL = "https://<replace-with-nextcloud-cloud-url>"
### NEXTCLOUD_USER = "<your-nextcloud-username>" # your username
### NEXTCLOUD_PASSWORD = "your-nextcloud-app-password" ### see details below
#3 For creating <your-nextcloud-app-password>:
#3.1 go to: https://replace-with-nextcloud-url/index.php/settings/user/security
#3.2 scroll down to create new app password
#3.3 select a name e.g. r-script and copy the token and replace your-nextcloud-app-password
#4 Finally you need to restart Rstudio and proceed with the code below:
paths_list <- list(site_code = "Pilot_A",
common_path = "ultimate/raw_data_pilots/<site_code>/data",
dir_cloud = "projects/<common_path>",
dir_local = "C:/kwb/projects/<common_path>")
paths <- kwb.utils::resolve(paths_list)
download_nextcloud_files(dir_cloud = paths$dir_cloud,
dir_local = paths$dir_local,
file_pattern = "Project\\.xls$"
)
}