Package 'kwb.nextcloud'

Title: R Package for Accessing Nextcloud Using WebDAV API
Description: R package to access file infos or download data from an Nextcloud instance using the WebDav API (https://docs.nextcloud.com/server/17/developer_manual/client_apis/WebDAV/).
Authors: Michael Rustler [aut, cre] , Hauke Sonnenberg [aut] , ULTIMATE [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph]
Maintainer: Michael Rustler <[email protected]>
License: MIT + file LICENSE
Version: 0.4.0
Built: 2024-11-14 05:30:20 UTC
Source: https://github.com/KWB-R/kwb.nextcloud

Help Index


Backup a Cloud Folder to a Local Zip File

Description

Zip cloud folder and download to local zip file. Default file name: <backup_dir>/cloud-backup_<base_name>_<yyyy-mm-dd-HHMM>.zip

Usage

backup_cloud_folder(
  path,
  target_file = get_download_target_file(base_name, backup_dir),
  user = nextcloud_user(),
  auth = nextcloud_auth(),
  backup_dir = kwb.utils::createDirectory("~/../Downloads/nextcloud-backups"),
  base_name = basename(path)
)

Arguments

path

path to folder on the cloud

target_file

path to the target file. A default path is provided by get_download_target_file(base_name, backup_dir)

user

user name, by default taken from the environment variable "NEXTCLOUD_USER".

auth

authentication header as provided by kwb.nextcloud:::nextcloud_auth

backup_dir

directory into which to download the zip-file

base_name

base name to be integrated into the name of the downloaded file


Compare Two Files Containing File Information

Description

Compare two CSV files as retrieved by list_files(..., full_info = TRUE)

Usage

compare_file_info_files(file_1, file_2, ...)

Arguments

file_1

path to first csv file

file_2

path to second csv file

...

further arguments passed to read.csv2


Create a Folder on the Cloud

Description

Create a Folder on the Cloud

Usage

create_folder(path, user = nextcloud_user(), auth = nextcloud_auth())

Arguments

path

path to the folder to be created

user

user name, by default taken from the environment variable "NEXTCLOUD_USER".

auth

authentication header as provided by kwb.nextcloud:::nextcloud_auth


Delete a File or Folder on the Cloud

Description

Delete a File or Folder on the Cloud

Usage

delete_file_or_folder(
  path,
  user = nextcloud_user(),
  auth = nextcloud_auth(),
  ...
)

Arguments

path

path to the file or folder to be deleted

user

user name, by default taken from the environment variable "NEXTCLOUD_USER".

auth

authentication header as provided by kwb.nextcloud:::nextcloud_auth

...

further arguments passed to kwb.nextcloud:::nextcloud_request


Download Files from Cloud

Description

Download Files from Cloud

Usage

download_files(
  hrefs = NULL,
  target_dir = create_download_dir("nextcloud_", dbg = dbg),
  paths = NULL,
  user = nextcloud_user(),
  auth = nextcloud_auth(),
  dbg = TRUE
)

Arguments

hrefs

href strings specifying the files to be downloaded. The href strings are returned by list_files. Alternatively, the paths to the files can be given in paths.

target_dir

path to local target directory

paths

Alternatively to givin the href strings, the paths to the files can be given in this argument.

user

name of nextcloud user. Default: result of calling kwb.nextcloud:::nextcloud_user

auth

authentication as returned by kwb.nextcloud:::nextcloud_user

dbg

logical indicating whether or not to show debug messages


Does a File Exist on the Nextcloud Server?

Description

Does a File Exist on the Nextcloud Server?

Usage

file_exists(path)

Arguments

path

path to the file

Value

TRUE if the file exists, else FALSE


Get Information on Versions of Given Files

Description

Get Information on Versions of Given Files

Usage

get_file_versions(file_info)

Arguments

file_info

data frame as returned by list_files when being called with full_info = TRUE

Value

data frame


Get Version Information on Files of Given IDs

Description

Get Version Information on Files of Given IDs

Usage

get_version_info(
  file_ids,
  user = nextcloud_user(),
  ignore = "^(status|quota|getcontent|resource)",
  dbg = TRUE
)

Arguments

file_ids

vector of integer representing file ids (values returned in column fileid) by list_files

user

nextcloud user

ignore

pattern matching columns to be excluded from the result. Set to NULL to see what columns are available.

dbg

logical indicating whether or not to print debug messages

Value

data frame with one row per version. There seems to be only an entry if the corresponding file as more than one version.


Deprecated: List File Versions

Description

Pleas use get_file_versions instead.

Usage

list_file_versions(path, pattern = NULL, ...)

Arguments

path

relative path to folder of which file versions are to be listed

pattern

optional. If specified, only files with names matching the pattern are considered.

...

additional arguments passed to list_files, such as recursive, max_depth


List Files on the Nextcloud Server

Description

List Files on the Nextcloud Server

Usage

list_files(
  path = "",
  pattern = NULL,
  recursive = FALSE,
  full_info = FALSE,
  user = nextcloud_user(),
  auth = nextcloud_auth(),
  max_depth = NA,
  ...
)

Arguments

path

path to the nextcloud folder to be listed

pattern

an optional regular expression. Only file names which match the regular expression will be returned.

recursive

if TRUE the contents of subfolders are listed as well, up to the given max_depth.

full_info

if TRUE the full file information is returned as a data frame. If FALSE (the default) only the (relative) file paths are returned as a vector of character.

user

user name, by default taken from the environment variable "NEXTCLOUD_USER".

auth

authentication header as provided by kwb.nextcloud:::nextcloud_auth

max_depth

maximum recursion depth if recursive = TRUE. By default max_depth is NA meaning that the function behaves "fully recursive".

...

further arguments passed to kwb.nextcloud:::list_cloud_files, such as silent = TRUE

Value

vector of character or data frame, each with attribute "root" being set to the value of path.


Move a File or Folder on the Cloud

Description

Move a File or Folder on the Cloud

Usage

move_file_or_folder(
  path,
  path_target,
  overwrite = FALSE,
  user = nextcloud_user(),
  auth = nextcloud_auth(),
  dbg = TRUE,
  ...
)

Arguments

path

path to the file or folder to be moved

path_target

path to the target file or folder to be moved to

overwrite

whether to overwrite the file or folder in case that the file or folder already exists (default: FALSE)

user

user name, by default taken from the environment variable "NEXTCLOUD_USER".

auth

authentication header as provided by kwb.nextcloud:::nextcloud_auth

dbg

print debug messages (default: TRUE)

...

further arguments passed to kwb.nextcloud:::nextcloud_request

Value

return path_target of moved file/folder


Convert Path to href as Required for Download

Description

Convert Path to href as Required for Download

Usage

path_to_file_href(path = "", user = nextcloud_user(), leading_slash = FALSE)

Arguments

path

path to file on Nextcloud server

user

name of Nextcloud user, default: kwb.nextcloud:::nextcloud_user()

leading_slash

should the returned href start with a slash?


Upload a Local File to the Cloud

Description

Upload a Local File to the Cloud

Usage

upload_file(
  file,
  target_path = "documents",
  user = nextcloud_user(),
  auth = nextcloud_auth()
)

Arguments

file

path to local file

target_path

path to folder on the cloud into which to upload the file

user

user name, by default taken from the environment variable "NEXTCLOUD_USER".

auth

authentication header as provided by kwb.nextcloud:::nextcloud_auth