downloadEvent
allows a custom reactive event to trigger a file
download.
downloadEvent(event, filename, handler,
domain = getDefaultReactiveDomain())
A reactive input value (e.g. input$click
), a call to a
reactive expression, or a new expression inside curly braces. When event
is triggered the file download is triggered.
A reactive input value, a call to a reactive expression, a function, or a new expression inside curly braces which returns a string specifying the name of the downloaded file.
A function with one argument that write's the content of the downloaded file. A temporary file is passed to the function, which is expected to write content (text, images, etc.) to the temporary file.
A shiny session object, defaults to
getDefaultReactiveDomain()
.
shinyApp( ui = container( textInput("name", "File name"), buttonInput("trigger", "Download") ), server = function(input, output) { downloadEvent(input$trigger, { if (is.null(input$name)) { "default" } else { input$name } }, function(file) { cat("hello, world!", file = file) }) } )
Other utilities: enableInput
,
invalidateInput
, updateInput