[R] shinyFiles update shinySaveButton filename varaible from server

nevil amos nev||@@mo@ @end|ng |rom gm@||@com
Fri Jun 4 07:59:00 CEST 2021


Is it possible to update the filename variable  the shinySaveButton from
the server?

I want to provide a default  filename based on a series of choices that the
user has made in the app ( here I have just made a random string to serve
the purpose.  how do I feed output$defaultname
 so that shinySaveButton( filename = outputSdefaultname )?


library(shiny)
library(shinyFiles)

data <- iris
roots <- c("UserFolder"=".")

ui <- fluidPage(
  actionButton("makeName","Make Default File Name"),
  shinySaveButton(id = "save", label = "Save file", title = "Save file as
...", filename = "defaultname",filetype=list(csv="csv"))
)


server <- shinyServer(function(input, output, session) {
  rv <- reactiveValues()
  observeEvent(input$makeName,{
    output$defaultname<-paste(letters[sample(1:10,5)],collapse="")
  })

  observe({


    shinyFileSave(input, "save", roots=roots, session=session)
    fileinfo <- parseSavePath(roots, input$save)
    xx<<-input$save
    if (nrow(fileinfo) > 0) {
      write.csv(, as.character(fileinfo$datapath))

    }
    session$allowReconnect("force")
  })
})

runApp(list(
  ui=ui,
  server=server
))

	[[alternative HTML version deleted]]



More information about the R-help mailing list