Creates a new version of a Zenodo record, or a new record, as a draft, sets its metadata, and optionally replaces its files. It never publishes: review the draft on Zenodo and publish it there.

zenodo_deposit(
  metadata,
  record,
  files = NULL,
  draft = NULL,
  sandbox = TRUE,
  token = NULL,
  allow_removals = FALSE
)

Arguments

metadata

Metadata from zenodo_metadata().

record

The concept record id (the number in the concept DOI, such as 3568417 for AusTraits) or the id of any of its published versions; the new version follows the latest. NA starts a new record instead. There is no default, so a release cannot start a new record by mistake.

files

Paths of the files the version should hold, or NULL to keep the previous version's files. Files in the draft that are not among these are deleted from the draft.

draft

The id of a draft to resume, such as one left by an interrupted upload. NULL creates a new draft (for a new version, Zenodo returns the draft already open for the record, if there is one).

sandbox

TRUE (the default) to use https://sandbox.zenodo.org, for trying a deposit; FALSE for https://zenodo.org.

token

A Zenodo personal access token with scope deposit:write. Defaults to the environment variable ZENODO_SANDBOX_TOKEN for the sandbox and ZENODO_TOKEN otherwise; tokens work on one server only.

allow_removals

What the new version may drop: TRUE for anything listed by the comparison, or the names, identifiers or references to accept as written in the comparison's message (such as "Wilson, J. Barstow", a spelling the datasets have corrected). Anything else dropped still stops the deposit.

Value

Invisibly, a list: id and url of the draft, the comparison from zenodo_compare() (NULL for a new record), and files, the names of the files uploaded.

Details

Before anything is written, the new metadata is compared with the latest published version's (zenodo_compare()). If a creator, contributor or related identifier would be dropped, or a creator's surname changes for the same ORCID, the deposit stops and lists them, unless allow_removals is TRUE. Add the missing people to project_contributors (or the related identifiers to related_identifiers) in config/metadata.yml instead, where they will be kept for later versions.

People who lack an ORCID or affiliation get those of the same person on the previous version, if any (listed in a message). The new metadata replaces these fields of the draft and keeps the rest from the previous version (such as keywords, communities and notes, and the grants unless zenodo_metadata() produced some). So a field emptied in config/metadata.yml keeps the previous version's value; clear it in the draft on Zenodo.

Files go up smallest first, and a file already in the draft with the same name and MD5 checksum is not uploaded again, so an interrupted upload can be resumed by running the same call with draft set to the draft's id.

Examples

if (FALSE) { # \dontrun{
metadata <- zenodo_metadata(austraits)
files <- c(list.files("export/data/austraits-8.0.0", full.names = TRUE), "README.md")
# Try it on the sandbox first, with a record there
zenodo_deposit(metadata, record = NA, files = files, sandbox = TRUE)
# Then the real deposit
zenodo_deposit(metadata, record = 3568417, files = files, sandbox = FALSE)
} # }