Hi All,
I've run into an issue with zipping files for download from a shiny app. This appears to be recent issue and everything was working until this issue being noticed a few days on a deployed app. The app.R code below allows a zipped folder to be downloaded. But when deployed on shinyapps.io the zipped folder cannot be downloaded. The logs from shinyapps.io show the error:
sh: 1: /usr/bin/zip: not found
Warning in system2(zip, args, input = input) : error in running command
It appears the path to the zip library cannot be found. Adding which zip
in the app code below shows a non zero exit ('1') in the logs, I think this means a zip library path cannot be found on the shiny server. Looking at the documented list of installed system dependency in Appendix 10 in the shiny User Guide shows that zip library should be available. It appears something is preventing zip function finding the path to the zip system library on the shiny server? But I have no idea how to fix this.
Any help greatly appreciated, many thanks Tim
library(shiny)
ui <- fluidPage(
titlePanel(""),
sidebarLayout(
sidebarPanel(
downloadButton("downloadData", label = "Download")
),
mainPanel(h6("Sample download", align = "center"))
)
)
server <- function(input, output) {
message(paste("zip lib path", system("which zip")))
output$downloadData <- downloadHandler(
filename = function() {
paste("output", "zip", sep = ".")
},
content = function(fname) {
fs <- c()
tmpdir <- tempdir()
setwd(tempdir())
for (i in c(1, 2, 3)) {
path <- paste0("sample_", i, ".csv")
fs <- c(fs, path)
write(i * 2, path)
}
zip(zipfile = fname, files = fs)
},
contentType = "application/zip"
)
}
# Run the application
shinyApp(ui = ui, server = server)