As I continue to work on my first shiny dashboard, I have been struggling with a task. I have a folder (with datasets) in my dropbox, and I want to be able to download a file from it as follows:
- a user chooses a file via selectInput()
- then he/she clicks the downloadButton() to save the file to a local machine.
So far, I only got to save a file (.html) that partially reproduces the app, and not the data file. I have tried different approaches (from what I have learned on the web) with no success. It follows the relevant pieces of my code. Thank you for any help!
Global
Get File Names from folder in dropbox
filenames <- function(){
drop_dir('Partners Files') %>%
pull()
}
UI piece
# To download a file
selectInput("dataset", "Choose a Dataset", choices = filenames()),
tableOutput("preview"),
downloadButton("download", "Download .csv"),
Server piece
To download a file
data_down <- reactive({
req(input$dataset())
})
When the Download a File button is clicked, save the data
observeEvent(input$download, {
drop_download(data_down())
})