Skip to contents

The file viewer module provides a tool to view static files. Supported formats include text formats, PDF, PNG, APNG, JPEG, SVG, WEBP, GIF and BMP.

Usage

tm_file_viewer(
  label = "File Viewer Module",
  input_path = list(`Current Working Directory` = ".")
)

Arguments

label

(character(1)) Label shown in the navigation item for the module. Any label possible except "global_filters" - read more in mapping argument of teal_slices.

input_path

optional, (list) of the input paths to either: specific files of accepted formats, a directory or a URL. The paths can be specified as absolute paths or relative to the running directory of the application. Will default to current working directory if not supplied.

Examples

data <- data.frame(1)
app <- teal::init(
  data = teal_data(
    dataset("data", data)
  ),
  modules = teal::modules(
    teal.modules.general::tm_file_viewer(
      input_path = list(
        folder = system.file("sample_files", package = "teal.modules.general"),
        png = system.file("sample_files/sample_file.png", package = "teal.modules.general"),
        txt = system.file("sample_files/sample_file.txt", package = "teal.modules.general"),
        url =
          "https://www.fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf"
      )
    )
  )
)
#> [INFO] 2023-08-14 13:51:32.0886 pid:1296 token:[] teal.modules.general Initializing tm_file_viewer
#> module "File Viewer Module" server function takes no data so "datanames" will be ignored
if (interactive()) {
  shinyApp(app$ui, app$server)
}