Skip to contents

Downloads a file from the private FOKUS repository and returns it as a character scalar in case of a text file, or a raw vector otherwise.

Usage

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

Arguments

path

File path relative to the repository root.

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 for text files, 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