Skip to contents

Creates a directory for the dataset and downloads all of its files. Returns (invisibly) a data frame with file info.

Usage

dryad_file_download(
  dryad_doi,
  download_to,
  max_file_size = 10,
  max_download_size = 100,
  unzip_types = NULL,
  pb = NULL
)

Arguments

dryad_doi

the dataset's DOI, or a URL containing it

download_to

path to download to; there is no default, because CRAN does not allow writing into the working directory unless you ask for it

max_file_size

maximum file size to download (in MB) - set to NULL or Inf for no restrictions

max_download_size

maximum total size to download - set to NULL or Inf for no restrictions

unzip_types

file categories to extract from .zip files in the dataset rather than downloading the zip whole, named as data_classify_files() names them: "data", "code", "materials", "documentation", "output", "unknown". More than one may be given. NULL (the default) downloads zips whole and leaves them zipped, as before. max_file_size applies to each extracted member rather than to the archive.

pb

a progress bar passed from another function

Value

data frame of file info. When members are extracted from a zip, its row reports the zip with extracted giving the number of members written; size_on_disk and checksum_ok are then NA, because what is on disk is the members rather than the archive Dryad published a size and digest for.

Details

A Dryad API token (see dryad_pat()) is REQUIRED to download file bytes, even from a fully public dataset – unlike figshare_file_download(), dataverse_file_download(), or zenodo_file_download(). Without one set, every file in the returned table has downloaded = FALSE: the dataset can still be listed (see dryad_info()), but nothing can be fetched.

You can limit downloads to only files under a specific size (defaults to 10MB) and only a maximum download size (largest files will be omitted until total size is under the limit). Omitted files will be listed as messages in verbose mode, and included in the returned data frame with the downloaded column value set to FALSE.

A .zip in the dataset is normally fetched whole and left as a zip. Set unzip_types to pull only the files you want out of it instead, the same as dataverse_file_download() and zenodo_file_download() do.

Examples

if (FALSE) { # \dontrun{
# Dryad needs a client id and secret for downloads (see dryad_auth())
dl <- dryad_file_download("10.5061/dryad.j1fd7",
                          download_to = file.path(tempdir(), "dryad"))

# take only the data files out of any zip in the dataset
dl <- dryad_file_download("10.5061/dryad.j1fd7",
                          download_to = file.path(tempdir(), "dryad"),
                          unzip_types = "data")
} # }