I have a Shiny web app. I want to create a downloadButton that would download a PowerPoint file when clicked. What do I need to put in the downloadHandler function in order to read in the PowerPoint file from some file path and then just download that file to the user who pressed the button?
Asked
Active
Viewed 1,369 times
1 Answers
5
You can use the file.copy
function. Below is a basic example for a file that is in c:/temp
.
library(shiny)
ui <- fluidPage(
downloadButton("downloadFile", "Download File")
)
server <- function(input, output) {
fileName <- "test.pptx"
filePath <- "c:/temp"
output$downloadFile <- downloadHandler(
filename = function() {
fileName # default file name use by browser, it could be different
},
content = function(file) {
file.copy(file.path(filePath, fileName), file)
}
)
}
shinyApp(ui = ui , server = server)

Geovany
- 5,389
- 21
- 37