content_id {contentid}R Documentation

Generate a content uri for a local file

Description

Generate a content uri for a local file

Usage

content_id(
  file,
  algos = default_algos(),
  raw = TRUE,
  as.data.frame = length(algos) > 1
)

Arguments

file

path to the file, URL, or a base::file connection

algos

Which algorithms should we compute contentid for? Default "sha256", see details.

raw

Logical, should compressed data be left as compressed binary?

as.data.frame

should the output be coerced into a data.frame? Default is FALSE if only one algorithm is computed, otherwise TRUE.

Details

See https://github.com/hash-uri/hash-uri for an overview of the content uri format and comparison to similar approaches.

Compressed file streams will have different raw (binary) and uncompressed hashes. Set raw = FALSE to allow base::file connection to uncompress common compression streams before calculating the hash, but this will be slower.

Value

a content identifier URI If multiple algorithms are requested, content_id will return a data.frame with one column per algorithm and one row for each input file. Otherwise it will return a character vector with one identifier URI for each input file. See argument as.data.frame above.

Examples



## local file
path <- system.file("extdata", "vostok.icecore.co2", package = "contentid")
content_id(path)


content_id(paste0("https://knb.ecoinformatics.org/knb/d1/mn/v2/object/",
                  "ess-dive-457358fdc81d3a5-20180726T203952542"))






[Package contentid version 0.0.18 Index]