Skip to contents

Downloads a file from the private FOKUS repository and returns it as a raw vector or a character scalar, depending on as_chr.

Usage

read_private_file(
  path,
  as_chr = FALSE,
  use_cache = TRUE,
  auth_token = pal::pkg_config_val("token_repo_private")
)

Arguments

path

File path relative to the repository root.

as_chr

Whether to return the file content as a character scalar, which is only recommended for text files. If FALSE, the file is returned as a raw vector instead.

use_cache

Whether or not to return cached results if possible. Caching is done based on file content hashing, so the file is only newly fetched if it actually changed since the last download. If FALSE, the file is always newly fetched.

auth_token

Personal access token of a gitlab.com account with access to the private FOKUS repository.

Value

The file content, as character scalar if as_chr, otherwise as a raw vector.

Details

Files are downloaded via GitLab's RESTful API (v4). If use_cache = TRUE (the default), a downloaded file is cached on disk in this package's user-cache pins board and only newly fetched from the private FOKUS repository GitLab remote if is has changed since being downloaded the last time. Caching saves a bit of time and (potentially) a lot of bandwidth.

Examples

# GitLab PAT with access to the private FOKUS repository is required for this function to work
try(
  fokus::read_private_file("raw/survey_data_2018-09-23_aargau.xlsx") |>
    length()
)
#> [1] 775593