我有一个闪亮的网络应用程序 . 我想创建一个downloadButton,可以在单击时下载PowerPoint文件 . 我需要在downloadHandler函数中放入什么才能从某个文件路径读取PowerPoint文件,然后将该文件下载到按下按钮的用户?
您可以使用 file.copy 功能 . 以下是 c:/temp 中文件的基本示例 .
file.copy
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)
1 回答
您可以使用
file.copy
功能 . 以下是c:/temp
中文件的基本示例 .