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

0

Issue

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!

Solution

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)

Answered By – Marco_CH

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More