Downloadhandler error .shp file

Hi,
I think the problem is that a shape file is not a single file, it is a set of 4+ files. What works for me is:

output$downloadShape <- downloadHandler(
    filename = "myShapeFiles.zip",
    content = function(file) {
      owd <- setwd(tempdir())
      on.exit(setwd(owd))
      tmpdir <- paste0(tempdir(), "/MyDir")
      setwd(tmpdir)
        ### This is a custom function that prepares the data and uses 
        ### writeOGR() to produce the .shp
        downloadSpatial(myObject, 
                        CRS = input$CRS, 
                        dsn = tmpdir)
       ### I scan the path where only the .shp and associated files 
      ### should be and zip them 
       zip(file, files=list.files(path = tmpdir))
    },
    contentType = "application/zip"
  )

cheers

Alejandro

2 Likes