Skip to contents

The building block behind as.img() and as.fileLink(): reads a file and returns its contents base64-encoded, ready to be placed in a data URI or in any container format that carries binary payloads as text.

Usage

embedFile(path)

Arguments

path

path to an existing file

Value

a single character string

Examples

fn <- tempfile(fileext = ".txt")
writeLines("hello", fn)
substr(embedFile(fn), 1, 8)
#> [1] "aGVsbG8K"
unlink(fn)