Learn R Programming

xfun (version 0.30)

base64_uri: Generate the Data URI for a file

Description

Encode the file in the base64 encoding, and add the media type. The data URI can be used to embed data in HTML documents, e.g., in the src attribute of the <img /> tag.

Usage

base64_uri(x)

Arguments

x

A file path.

Value

A string of the form data:<media type>;base64,<data>.

Examples

Run this code
# NOT RUN {
logo = xfun:::R_logo()
img = htmltools::img(src = xfun::base64_uri(logo), alt = "R logo")
if (interactive()) htmltools::browsable(img)
# }

Run the code above in your browser using DataLab