In the code below, I am just using simple downloadButton()
example. It works just fine. But, Why changing the output file name after the "Save File" window pops up, will save the file with no extension (removes the .csv)?
library(shiny)
downloadUI <- function(id){
ns <- NS(id)
downloadButton(ns("downloadData"), "Download")
}
downloadServer <- function(id){
moduleServer(id,
function(input, output, session){
# Our dataset
data <- iris
output$downloadData <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".csv", sep="")
},
content = function(file) {
write.csv(data, file)
}
)
}
)
}
ui <- fluidPage(
downloadUI("irisDownload")
)
server <- function(input, output, session) {
downloadServer("irisDownload")
}
shinyApp(ui, server)