R: Create a data URI string

dataURI {base64enc} | R Documentation

## Create a data URI string

### Description

`dataURI` creates URI with the `data:` scheme by encoding the payload either using base64 ot URI encoding.

### Usage

    dataURI(data, mime = "", encoding = "base64", file)

### Arguments

`data` | raw vector, connection or character vector to use as payload. Character vectors of more than one element are collapsed using `"\n"` before encoding.
`mime` | MIME-type of the data (per standard "" is interpreted as "text/plain;charset=US-ASCII" without including it in the URI)
`encoding` | data encoding to use. Must be either `"base64"` or `NULL`
`file` | filename (string) to open as payload. `file` and `data` are mutually exclusive

### Value

string of the form `data:[mime][;base64],<encoded-payload>`

### Author(s)

Simon Urbanek

### References

RFC 2397 The "data" URL scheme

### Examples

      dataURI(as.raw(1:10)) # default is base64
      dataURI(as.raw(1:10), encoding=NULL) # URI
      if (require("png", quietly=TRUE)) {
        # let's say you have an image - e.g. from dev.capture(TRUE)
        img <- matrix(1:16/16, 4)
        dataURI(writePNG(img), "image/png")
        # or straight from a file
        dataURI(file=system.file("img", "Rlogo.png", package="png"), mime="image/png")
      }

[Package base64enc version 0.1-3 Index]