a_in_mem_asset: a_in_mem_asset()

Description Usage Arguments Details Value

View source: R/in_mem_asset.R

Description

Create an A-Frame asset hosted in R's memory.

Usage

1
a_in_mem_asset(.data, src, .parts = NULL, ...)

Arguments

.data

a string containing file content or a list of such strings.

src

a realistic path to a notional file. The path is used to set the route the used by the scene server for the in memory asset. The file extension of the is used to set the HTTP content header mime type.

.parts

additional notional files referenced in the content of 'data'. Unlike 'src' the names used here matter, e.g. if the 'src' file is a model that references textures, those textures need to be mapped by relative path inside 'src' the paths provided for 'parts' must be compatible with these. When 'data' is a list, elements after the first are assumed to be the in-memory content of 'parts', matched by list position.

...

additional parameters passed to 'a_asset()'

Details

To understand this object you will almost certainly need to familiarise yourself with its base class 'A_Asset' first. See a_asset.

This function is used to create a special kind of A-Frame asset that is only notionally backed by a file. The primary use of this is for passing CRAN's vignette checks, testing, and demonstration. From the end-user's perspective an in-memory-asset appears exactly like a regular asset file. However the scene creates a route to 'src' and 'parts' that reference the contents of 'data' rather than files specified by the paths in 'src' and 'parts'.

An example usecase: Serving a JSON transform of an built-in R dataframe as an asset without writing an intermediate JSON file to disk.

It is still necessary to supply a 'real looking' path to the asset. The path must be relative to the current R working directory, but other than that is doesn't matter what it is. The most important aspect of this notional path is the file extension, since this is used to determine the HTTP mime-type header when the asset is served.

'data' is either a length one character vector or a list of length one character vectors. It must have the same length as the number of paths supplied in 'src' + 'parts'. The character vectors are strings that contain the entire contents of a notional file. For non-text files they would need to contain the equivalent encoded text of calling readr::read_file_raw().

Value

an asset object.


MilesMcBain/r2vr documentation built on Dec. 8, 2018, 10:13 a.m.