load_rocrate_bag: Load an RO-Crate BagIt archive

View source: R/utils-bag.R

load_rocrate_bagR Documentation

Load an RO-Crate BagIt archive

Description

Load an RO-Crate BagIt archive

Usage

load_rocrate_bag(
  path,
  algo = NULL,
  bagit_version = "1.0",
  load_content = FALSE,
  max_file_size = 10 * 1024^2
)

Arguments

path

String with full path to a compressed file contain an RO-Crate bag, see bag_rocrate for details. Alternatively, a path to a directory containing an RO-Crate bag.

algo

String with algorithm used to generate the RO-Crate bag (default: NULL, which auto detects the algorithm from the ⁠manifest-<algo>.txt⁠ file, inside the bag). See digest for more details on valid algorithms.

bagit_version

String with version of BagIt used to generate the RO-Crate bag (default: "1.0"). See \Sexpr[results=rd]{tools:::Rd_expr_doi("10.17487/RFC8493")} for more details.

load_content

Logical. If TRUE , attempt to load external file contents into the content field for entities of type File.

max_file_size

Maximum file size (bytes) allowed when loading content. Default 10MB.

Value

An object with the rocrate class.

See Also

Other RO-Crate BagIt archive functions: bag_rocrate(), is_rocrate_bag(), unbag_rocrate()

Examples

# -------- SETUP --------
basic_crate <- rocrateR::rocrate()
# temp file
tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile())))
tmp <- file.path(tmp_dir, "ro-crate-metadata.json")
dir.create(tmp_dir)

# bag RO-Crate
path_to_roc_bag <- rocrateR::bag_rocrate(basic_crate, path = tmp_dir)

# -------- INPUT: RO-Crate BagIt archive --------
rocrateR::load_rocrate_bag(path_to_roc_bag)

# -------- INPUT: Path --------
rocrateR::unbag_rocrate(path_to_roc_bag) |>
  rocrateR::load_rocrate_bag()

# delete temp directory
unlink(tmp_dir, recursive = TRUE)

rocrateR documentation built on April 9, 2026, 1:06 a.m.