selectFileServer: Module Server function for file selection

View source: R/selectFileModule.r

selectFileServerR Documentation

Module Server function for file selection

Description

Module Server function for file selection

Usage

selectFileServer(id, root_dirs = c(root = "."), filetypes = NULL)

Arguments

id

string namespace id for module (same as in server)

root_dirs

named list of paths that for the root directories within which files may be selected default is the cwd ie c(root = "."))

filetypes

vector of filetypes (by file extension) that may be selected from eg c("txt", "csv", "gpkg")

Details

Select File Module UI used with selectFileUI modified from https://stackoverflow.com/questions/38747129/how-to-use-shinyfiles-package-within-shiny-modules-namespace-issue

Value

filepath as reactiveValue named same as module id ( relative to root_dirs argument in fileSelectServer)

Examples

#simple file selection shiny app
library(shiny)
ui <-   fluidPage(
 selectFileUI(
   id = "fileSelect1",label ="Select File"
 ),
 textOutput("datapath")

)

server <- function(input, output, session) {
 rv<-reactiveValues()
 x <- selectFileServer(id = "fileSelect1")
 observe(rv$datapath<-x$datapath)
 observe(output$datapath<-renderText(rv$datapath))


}
shinyApp(ui,server)

nevilamos/FAMEFMR documentation built on April 17, 2025, 9:32 p.m.