Hello team,
I am seeking help with handling downloadhandler asynchronously in a shiny app. I have posted this question on stack overflow though I haven't gotten any answers yet.
Below is a reprex of how my downloadhandler looks like:
library(shiny)
ui <- fluidPage(
downloadButton("Download", "Download")
)
server <- function(input, output){
output$Download <- downloadHandler(
filename = "Downloads.zip",
content = function(file){
withProgress(message = "Writing Files to Disk. Please wait...", {
temp <- setwd(tempdir())
on.exit(setwd(temp))
files <- c("mtcars.csv", "iris.csv")
write.csv(mtcars, "mtcars.csv")
write.csv(iris, "iris.csv")
zip(zipfile = file, files = files)
})
}
)
}
shinyApp(ui, server)
I would love to have the app available for other users when one user clicks the download button. I've tried wrapping the write.csv
inside a future
function and setting `and while this does not throw an error, the app is not available for other users during the download.
I've also tried wrapping the entire downloadHandler
function inside the future
function, but I get the error:
Error in .subset2(x, "impl")$defineOutput(name, value, label) :
Unexpected MulticoreFuture output for DownloadUnexpected MultiprocessFuture output for DownloadUnexpected Future output for DownloadUnexpected environment output for Download
How can I handle the entire downloadHandler
asyncronously? I am using the open source version of shiny server.