downloadHandler - zip file

Hello,

I am using downloadButton widget and downloadHandler server side. I would like to download a folder. To do this I have to zip the folder.

When i click on download button i get a text document type file. When I save it, I get nothing.

# print(getwd()) [1] "C:/Users/user/Workspace/project/shinyapp" 
# the folder is in : "C:/Users/user/Workspace/project/results" 
downloadHandler(
          filename = function(){ paste0("zipfile", ".zip") },
          content = function(file){ 
           # print(file) "C:\\Users\\user~1\\AppData\\Local\\Temp\\RtmpsrFrQB\\file42a44f144187.zip"
            tempZip <- tempfile()
           # print(tempZip") "C:\\Users\\user~1\\AppData\\Local\\Temp\\RtmpsrFrQB\\file42a432e645aa"
            zip(tempZip, files = "../results/folder")
            file.copy(tempZip, file)
          },
          contentType = "application/zip"
        )

it was necessary to add fileext = ".zip" in tempfile()
tempZip <- tempfile(fileext = ".zip")

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.