I am building an app, from which user can csv download files, i am using download handler for downloading the csv files. Each time user downloads a file , a modal message will appear to let the user know if download is completed. The problem is even when the user not saving the file/or cancelling the download window, the modal box is appearing as "download completed", is there a way to make the modal box to respond only when the user successfully downloaded file?(i am assuming user can chose any directory)
attaching the sample code below :
library(shiny)
ui <- fluidPage(
downloadButton("downloadData", "Download")
)
server <- function(input, output) {
# Our dataset
data <- mtcars
output$downloadData <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".csv", sep="")
},
content = function(file) {
write.csv(data, file)
showModal(modalDialog(
title = "Download Complete",
easyClose = TRUE,
footer = NULL))
}
)
}
shinyApp(ui, server)