shinyFiles (version 0.3.2)

parseFilePaths: Convert the output of a file choice to a data frame

Description

This function takes the value of a shinyFiles button input variable and converts it to a data frame of the same format as that provided by fileInput. The only caveat is that the MIME type cannot be inferred so this will always be an empty string.

Usage

parseFilePaths(roots, files)

Arguments

roots
The path to the root as specified in the shinyFileChoose() call in shinyServer()
files
The corresponding input variable to be parsed

Value

  • A data frame mathcing the format of link[shiny]{fileInput}

Details

The use of parseFilePaths makes it easy to substitute fileInput and shinyFiles in your code as code that relies on the values of a file selection doesn't have to change.

See Also

Other shinyFiles: shinyFileChoose; shinyFilesButton; shinyFilesExample

Examples

Run this code
ui <- shinyUI(bootstrapPage(
    shinyFilesButton('files', 'File select', 'Please select a file', FALSE)
    verbatimTextOutput('filepaths')
))
server <- shinyServer(function(input, output) {
    output$files <- shinyFileChoose(input, 'files', roots=c(wd='.'),
    filetypes=c('', '.txt'))
    output$filepaths <- renderText({parseFilePaths('.', input$files)})
})

runApp(list(
    ui=ui,
    server=server
))

Run the code above in your browser using DataLab