This Shiny Module was created in order to provide a consistent-looking and easy-to-use button that facilitates one or multiple types of file downloads.
Shiny modules consist of a pair of functions that modularize, or package, a small piece of reusable functionality. The UI function is called directly by the user to place the UI in the correct location (as with other shiny UI objects). The module server function that is called only once to set it up using the module name as a function inside the server function (i.e. user-local session scope. The function first arguments is string represents the module id (the same id used in module UI function). Additional arguments can be supplied by the user based on the specific shiny module that is called. There can be additional helper functions that are a part of a shiny module.
The downloadFile Shiny Module is a part of the periscope package and consists of the following functions:
The downloadFile function is called directly. The call consists of the following:
Data Function Requirements
# Inside server_local.R
#single download type
downloadFile("object_id1",
logger = ss_userAction.Log,
filenameroot = "mydownload1",
datafxns = list(csv = mydatafxn1),
aspectratio = 1)
#multiple download types
downloadFile("object_id2",
logger = ss_userAction.Log,
filenameroot = "mytype2",
datafxns = list(csv = mydatafxn1, xlsx = mydatafxn2),
aspectratio = 1)
For a complete running shiny example application using the downloadableTable module you can create and run a periscope sample application using:
library(periscope)
= tempdir()
app_dir create_new_application('mysampleapp', location = app_dir, sampleapp = TRUE)
runApp(paste(app_dir, 'mysampleapp', sep = .Platform$file.sep))