Skip to contents

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

Usage

reshare_file_download(
  reshare_id,
  download_to,
  max_file_size = 10,
  max_download_size = 100,
  unzip_types = NULL,
  pb = NULL
)

Arguments

reshare_id

a ReShare eprint ID, URL, or DOI

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 deposit 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 ReShare published a size and MD5 for.

Details

Like Figshare, ReShare's EPrints REST API documents no whole-deposit bulk-download endpoint – each file is served from its own .../id/file/<fileid> URL, so this always downloads file by file. A .zip already present in the deposit (ReShare's own documents are frequently zips of related files, e.g. all interviews for one country) is still handled the same way dataverse_file_download() handles one: fetched whole and left as a zip unless unzip_types asks for only specific members out of it.

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.

Examples

# \donttest{
if (online("reshare.ukdataservice.ac.uk")) {
  dl <- reshare_file_download("854001",
                              download_to = file.path(tempdir(), "reshare"),
                              max_download_size = 10)
}
# }