shinyFiles-parsers: Convert the output of a selection to platform specific...

Description Usage Arguments Details Value See Also Examples

Description

This function takes the value of a shinyFiles button input variable and converts it to be easier to work with on the server side. In the case of file selections and saving the input variable is converted to a data frame (using parseFilePaths() or parseSavePath() respectively) of the same format as that provided by fileInput. The only caveat here is that the MIME type cannot be inferred in file selections so this will always be an empty string and new files doesn't have a size so this is left out with file saving. In the case of folder selection the input variable is converted to a string (using parseDirPath()) giving the absolute path to the selected folder.

Usage

1
2
3
4
5
parseFilePaths(roots, selection)

parseDirPath(roots, selection)

parseSavePath(roots, selection)

Arguments

roots

The path to the root as specified in the shinyFileChoose() call in shinyServer()

selection

The corresponding input variable to be parsed

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.

Value

A data frame mathcing the format of fileInput

See Also

Other shinyFiles: shinyFiles-buttons, shinyFiles-observers

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
ui <- shinyUI(bootstrapPage(
    shinyFilesButton('files', 'File select', 'Please select a file', FALSE),
    verbatimTextOutput('rawInputValue'),
    verbatimTextOutput('filepaths')
))
server <- shinyServer(function(input, output) {
    roots = c(wd='.')
    shinyFileChoose(input, 'files', roots=roots, filetypes=c('', 'txt'))
    output$rawInputValue <- renderPrint({str(input$files)})
    output$filepaths <- renderPrint({parseFilePaths(roots, input$files)})
})

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

## End(Not run)

moj-analytical-services/s3browser documentation built on May 20, 2019, 1:57 p.m.