
Fetch selected files out of a .zip in a Zenodo record without downloading it
Source:R/archive-zenodo.R
dot-zenodo_zip_members.RdA zip published on Zenodo is often mostly material a reader does not need:
stimuli, images, or videos alongside the few data files. Zenodo serves its
per-file URLs with byte-range support, and every member of a zip is
compressed on its own, so individual members can be pulled out of the archive
while the rest is never transferred (see .zip_member_fetch()). Verified
2026-08-13 on record 13384475: one 2.06 MB member out of a 129.8 MB archive
in about half a second.
Usage
.zenodo_zip_members(
url,
dest,
keep_types = c("data", "documentation"),
max_file_size = 10,
size = NULL
)Arguments
- url
the zip's
selfdownload URL in the record- dest
directory to write the extracted members into
- keep_types
file categories worth extracting, as
data_classify_files()names them; the default keeps data and documentation and skips materials, matchingzip_decision()- max_file_size
largest member to extract (in MB), applied per member exactly as the record-level cap is applied per file
- size
the zip's size in bytes as the record lists it, or
NULL. Passed on tozip_peek()so it does not have to send aHEADrequest to learn a size the record listing already gave.
Value
a data frame with one row per extracted member (name, path,
size, ok), or NULL when the archive could not be listed and the
caller should download it whole instead
Details
This is not possible for every archive. .7z, .rar and .tar.gz compress
all their files as one stream, so nothing inside can be read without
decompressing everything before it, and Zenodo's own whole-record
files-archive endpoint ignores range requests entirely. Both cases fall
back to downloading the archive whole.