Get the local path to a Zenodo deposit file. It not cached in a mirror yet, it will download the file to a deposit mirror cache locally.
Usage
zen_file(
deposit_id,
file_name,
cache_type = NULL,
cache_dir = NULL,
clear_cache = FALSE,
quiet = FALSE
)
Arguments
- deposit_id
numeric. The Zenodo deposit id.
- file_name
character. If
NULL
, all files from the file list. If a file name is specified, only this file will be downloaded.- cache_type
character. Use
temporary
to a session temporary folder,persistent
for a persistent cache folder orNULL
to use the environment default. Check the section Cache Type for more details.- cache_dir
character. User specified cache directory for persistent cache type.
- clear_cache
logical. If the mirror already exists, clear its content.
- quiet
logical. Show download info and progress bar.
Cache type
The Zenodo mirror will be cached locally on a system folder. This folder can be temporary, being cleared when the R session is ended, or persistent across sections and reboots.
If the cache_type
argument is NULL
(the default) the package will check first the environment variable zendown_cache_type
. If set, the package will use its value. If not set, a temporary cache folder will be used as default.
You can set an environment variable with usethis::edit_r_environ()
and write as bellow for a persistent cache storage.
zendown_cache_type = "persistent"
After saving the file, remember to restart the session. With this setting, the cache will be persistent and stored at the directory given by tools::R_user_dir("zendown", which = "cache")
You may also use a different folder for persistent storage by setting the zendown_cache_dir
environment variable. For example:
zendown_cache_dir = C:\my_cache\
If you set the cache_type
argument directly as temporary
or persistent
, it will override the environment setting.
Examples
# https://zenodo.org/records/10959197
zen_file_path <- zen_file(10959197, "iris.rds")
print(zen_file_path)
#> /tmp/Rtmpy6qK26/zendown/10959197/iris.rds
file.exists(zen_file_path)
#> [1] TRUE