download_safe_files: Download SAFE dataset files

View source: R/load_safe.R

download_safe_filesR Documentation

Download SAFE dataset files

Description

This downloads files associated with SAFE datasets, either all of the files included in a set of records (xlsx_only = FALSE) or just the core .xlsx files (xlsx_only = FALSE), and stores them in the SAFE data directory. See insert_dataset for details on using embargoed or restricted datasets.

Usage

download_safe_files(
  record_ids,
  confirm = TRUE,
  xlsx_only = TRUE,
  download_metadata = TRUE,
  refresh = FALSE,
  token = NULL
)

Arguments

record_ids

A vector of SAFE dataset record ids or a safe_record_set object.

confirm

Requires the user to confirm before download (logical)

xlsx_only

Should all files be downloaded or just the core .xslx file (logical)

download_metadata

Should the metadata record for the file be downloaded (logical)

refresh

Should the function check if local copies have been modified and download fresh copies. This is useful if the local copies have unintentionally been modified but note the warning above.

token

An access token for restricted datasets. These tokens are requested through the Zenodo page for a restricted dataset and are long alphanumeric strings. If you are providing a token, you should only provide the record id for that dataset.

Details

By default, the function will also download the dataset metadata. This information is required by many of the functions in the package but users can turn off automatic metadata download.

Value

Invisibly, a vector of paths within the 'safe_dir' for successfully downloaded files. If the download is not successful then the function returns FALSE.

Warning

Using refresh = TRUE will overwrite locally modified files and replace them with the versions of record from Zenodo.

Examples

   
       set_example_safe_dir()
       recs <- validate_record_ids(c(3247631, 3266827, 3266821))
       download_safe_files(recs, confirm = FALSE)
       unset_example_safe_dir()
   
   ## Not run: 
       # This example requires a private token
       download_safe_files(1237730, confirm = FALSE,
                           token="longStringFromZenodo")
   
## End(Not run)

safedata documentation built on May 31, 2023, 9:01 p.m.