This is a cross-post from Stackoverflow (where I didn't get any response so far )
Let's say we have the following minimal shiny app:
library(shiny)
app <- list(
ui = fluidPage(
downloadButton("downloadData", label = "Download")
),
server = function(input, output) {
output$downloadData <- downloadHandler(
filename = "data.csv",
content <- function(file) {
print("Download started") # Function call log
write.csv(mtcars, file)
}
)
}
)
shiny::runApp(app)
As you can see, I can call print()
to "log" to the standard output when the download of "data.csv" has been started.
However, the download can fail for many different reasons: e.g. the user cancels the download, they choose a directory without write permission, or try to save to a drive that has no available space.
Is there a way I could log when the download has finished successfully (or not)? The help page for shiny::downloadHandler()
doesn't provide info about this, and I haven't been able to find anything of the sort in StackOverflow or elsewhere.
Thanks!