R Shiny Save to Server

Viewed 2970

I'm building an R Shiny app that acts as a GUI for a simulation model my team has built. The user defines parameters, clicks run, and the model produces a bunch of charts and tables as output. My problem is, every time the user opens the app they have to enter in their parameters again. I'd like them to be able to save their parameters and bring them up again when they go back to the app.

My initial approach was to have the user download the parameters in a csv using downloadHandler to their local machine, and then upload them in their next session. This is not workable because there is too much risk that the formatting will get messed up or the user will make changes to the file, and then I'll have errors when they upload it again.

What I think makes the most sense is to save the parameters in a file on the server (I'd prefer an .Rdata file, so I can save the parameters in lists), and use a selectInput widget to allow the user to call up the parameter file they want. I have no idea how to save to the server from within a Shiny app, or how to get downloadHandler to do this.

EDIT For example, when I do this: UI:

downloadLink("saveParams",label="Save Your Model")

Server:

 output$saveParams <- downloadHandler(
    filename <- function(){
      paste0(input$nameModel,".RData")
    },

    content = function(file) {
      inputparams<-inputparams()
      save(inputparams, file = file)
    }
  )

It gives the user the option of where to save the file, which I want to avoid. I want it automatically to drop it onto the server. I tried using an actionButton to trigger a reactive that used save but couldn't get it to run. Any suggestions?

1 Answers
Related