Hello!
In my Shiny app, I run calculations, generate a data frame, and want the user to be able to save (download) it.
My relevant code in ui.R:
textInput("downFile","Save the File:", value = "Results File"),
downloadButton('downFile',"Save File")
My relevant code in server.R:
output$downFile <- downloadHandler(
filename = function() {
paste0(input$downFile, " ", Sys.Date(), ".csv")
},
content = function(file) {
write.csv(MyMainFunction()$mydataframe, file, row.names = FALSE)
}
)
Everything works. But I have two issues:
- If by mistake the user clicks on "Save File" before all the calculations in server.R have been completed, he gets an error ("Failed - Network Error").
- After all the calculations, when the user clicks on the "Save File" button, the file is immediately saved in "Downloads" folder.
Two questions:
Is it possible to make the button invisible until the calculations in my main function (MainFunction) are completed?
How could I allow the user to select a desired folder to download the results to? (as in "Save in...")
Thank you so much!