Hi,
Another option is setting a temp folder and zipping from there. This will be automatically deleted anyway.
library(shiny)
ui <- fluidPage(
textInput("id", "ID", "1335913"),
downloadButton("download", "Download")
)
server <- function(input, output, session) {
output$download <- downloadHandler(
filename = function() {
paste0(input$id, ".zip")
},
content = function(file) {
myDir = tempdir()
write.csv(mtcars, paste0(myDir, "/mtcars.csv"))
zip(file, paste0(myDir, "/mtcars.csv"), flags = "-r9Xj")
},
contentType = "application/zip"
)
}
shinyApp(ui, server)
Note that I added to the flags argument a j (j for junk path) to ensure that the folder structure does not get saved in the zip, just the file.
PJ