| Title: | Access Files from 'Zenodo' Deposits |
|---|---|
| Description: | Access, download and locally cache files deposited on 'Zenodo' <https://zenodo.org>. |
| Authors: | Raphael Saldanha [aut, cre] (ORCID: <https://orcid.org/0000-0003-0652-8466>) |
| Maintainer: | Raphael Saldanha <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-26 05:59:10 UTC |
| Source: | https://github.com/rfsaldanha/zendown |
Print a report at the console with cache statistics
cache_report(cache_type = NULL, cache_dir = NULL)cache_report(cache_type = NULL, cache_dir = NULL)
cache_type |
character. Use |
cache_dir |
character. User specified cache directory for persistent cache type. |
No return value. The function prints a report on the console.
mirror_deposit(deposit_id = 10959197) cache_report()mirror_deposit(deposit_id = 10959197) cache_report()
This function will delete all mirrored files stored locally.
delete_mirror(deposit_id, cache_type = NULL, cache_dir = NULL)delete_mirror(deposit_id, cache_type = NULL, cache_dir = NULL)
deposit_id |
numeric. The Zenodo deposit id. |
cache_type |
character. Use |
cache_dir |
character. User specified cache directory for persistent cache type. |
No return value. The function deletes mirrored on the system.
# https://zenodo.org/records/10959197 file_path <- zen_file(10959197, "iris.rds") print(file_path) file.exists(file_path) delete_mirror(10959197) file.exists(file_path)# https://zenodo.org/records/10959197 file_path <- zen_file(10959197, "iris.rds") print(file_path) file.exists(file_path) delete_mirror(10959197) file.exists(file_path)
Download files from a Zenodo deposit
download_deposit(list_deposit, file_name = NULL, dest, quiet = FALSE)download_deposit(list_deposit, file_name = NULL, dest, quiet = FALSE)
list_deposit |
data.frame or tibble. Obtained with list_deposit. |
file_name |
character. If |
dest |
character. Destination folder. |
quiet |
logical. Show download info and progress bar. |
No return value. The function downloads files to the specified destination.
res <- list_deposit(deposit_id = 10959197) temp_dir <- tempdir() download_deposit(list_deposit = res, dest = temp_dir, quiet = FALSE) file.exists(file.path(temp_dir, "iris.rds")) file.exists(file.path(temp_dir, "mtcars.rds"))res <- list_deposit(deposit_id = 10959197) temp_dir <- tempdir() download_deposit(list_deposit = res, dest = temp_dir, quiet = FALSE) file.exists(file.path(temp_dir, "iris.rds")) file.exists(file.path(temp_dir, "mtcars.rds"))
Get a list of files available at a Zenodo deposit
list_deposit(deposit_id)list_deposit(deposit_id)
deposit_id |
numeric. The Zenodo deposit id. |
a tibble.
# https://zenodo.org/records/10959197 list_deposit(deposit_id = 10959197)# https://zenodo.org/records/10959197 list_deposit(deposit_id = 10959197)
Mirror an entire Zenodo deposit or a specific file locally. The mirror is a folder with the deposit files created at the cache folder of the operating system.
mirror_deposit( deposit_id, file_name = NULL, cache_dir = NULL, cache_type = NULL, clear_cache = FALSE, quiet = FALSE )mirror_deposit( deposit_id, file_name = NULL, cache_dir = NULL, cache_type = NULL, clear_cache = FALSE, quiet = FALSE )
deposit_id |
numeric. The Zenodo deposit id. |
file_name |
character. If |
cache_dir |
character. User specified cache directory for persistent cache type. |
cache_type |
character. Use |
clear_cache |
logical. If the mirror already exists, clear its content. |
quiet |
logical. Show download info and progress bar. |
a string with the mirror path.
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.
# https://zenodo.org/records/10959197 mirror_path <- mirror_deposit(deposit_id = 10959197) file.exists(file.path(mirror_path, "iris.rds")) file.exists(file.path(mirror_path, "mtcars.rds"))# https://zenodo.org/records/10959197 mirror_path <- mirror_deposit(deposit_id = 10959197) file.exists(file.path(mirror_path, "iris.rds")) file.exists(file.path(mirror_path, "mtcars.rds"))
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.
zen_file( deposit_id, file_name, cache_type = NULL, cache_dir = NULL, clear_cache = FALSE, quiet = FALSE )zen_file( deposit_id, file_name, cache_type = NULL, cache_dir = NULL, clear_cache = FALSE, quiet = FALSE )
deposit_id |
numeric. The Zenodo deposit id. |
file_name |
character. If |
cache_type |
character. Use |
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. |
a string with the mirror file path.
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.
# https://zenodo.org/records/10959197 zen_file_path <- zen_file(10959197, "iris.rds") print(zen_file_path) file.exists(zen_file_path)# https://zenodo.org/records/10959197 zen_file_path <- zen_file(10959197, "iris.rds") print(zen_file_path) file.exists(zen_file_path)