woggles
woggles

Reputation: 99

What does it mean when R Shiny app downloadHandler only opens a new tab with new instance of app, no download?

I have a Shiny app that includes multiple uses of downloadHandler() to trigger downloads of .csv, .rmd, and .zip files. It's supposed to just trigger download, but instead all of the downloadHandlers except for one just open a new browser tab with a new instance of the app running, except for one. That random one (formatted identically to the others) correctly triggers a download and no new tab opens.

Apart from the specific code that I'm using, what does it mean when downloadHandler() causes a new browser tab to open running a new instance of the app, with no download?

Thanks!

Upvotes: 1

Views: 701

Answers (1)

Marco_CH
Marco_CH

Reputation: 3294

I was facing the same issue and found this solution which worked for me:

library(shiny)

ui = fluidPage(actionButton("Download", "Download"))

server =  function(input, output) {
  observe({
    if (input$Download == TRUE){
      filename= paste0(Sys.Date(), "_iris.csv")
      write.csv(iris, filename)
    }
  })
}
shinyApp(ui = ui, 
         server = server)

Upvotes: 1

Related Questions