I am creating R Shiny application in which I have a dropdown (selectInput) of documents list and a download button. So functionality is Users will select a document from the list and download that doc using download button.
in UI.R
tabItem(tabName = "Downloads",
selectInput("filenames", "Choose a document to download:",list.files(path="/srv/shiny-server/apps/dsw/files")),
downloadButton('downloadData', 'Download')),
in Server.R
datasetInput <- reactive({
switch(input$filenames,input$filenames)
})
output$downloadData <- downloadHandler(
filename = function() {
paste(input$filenames)
},
content = function(file) {
write.csv(datasetInput(), file)
}
)
These documents I have placed on Linux server in the www folder of my shiny application.
myapp
--app.R
--files
-- Doc1.doc
-- Doc2.csv
When I run the application, it just downloads empty .csv or .docx file but not the actual file from server.
datasetInput()
function? Please, make reproducable code so we can identify the error. – AK47