Get directory of shiny bookmark

Hello,

Is there a function that returns the directory for the bookmarks that shiny is using?
That is probably a simple question but I could not find an answer for this.

Thanks!

You can get the current bookmark directory e.g. via the onBookmark callback:

ui <- function(request) {
  fluidPage(
    textInput("txt", "Enter text"),
    checkboxInput("caps", "Capitalize"),
    verbatimTextOutput("out"),
    bookmarkButton(),
    p(),
    textOutput("currentbookmarkDir")
  )
}
server <- function(input, output, session) {
  output$out <- renderText({
    if (input$caps)
      toupper(input$txt)
    else
      input$txt
  })
  
  bookmarkDir <- reactiveVal()
  
  onBookmark(function(state){
    bookmarkDir(state$dir)
  })
  
  output$currentbookmarkDir <- renderText(bookmarkDir())
  
}

shinyApp(ui, server, enableBookmarking = "server")

For further information please see:

https://shiny.rstudio.com/articles/advanced-bookmarking.html

I was hoping for a function that could return the bookmark directory before any bookmark is created. How is shiny-server choosing a directory? In runApp() it seems to create shiny-bookmarks directory. But in shiny-server the name seems to be the app name together with a random hash.

I should clarify the question. I have the following shiny config and would like to know the bookmark directory for the apps running on that server before a bookmark was created. I would like to copy bookmarks from someone else and put them into that directory.

run_as shiny;

server {

  listen 6860;

  location / {

    # This is that makes the /apps URL component work
    # site_dir /srv/shiny-server;
		site_dir /datashare/apps;

    # The Shiny Server logs will go to a place on your host vs in the VM
    log_dir /var/log/shiny-server;

		# bookmarks
		bookmark_state_dir /datashare/shiny_bookmarks;

		# timeouts
		app_idle_timeout 0;

    directory_index on;

  }

}

Using shiny-server the directory can be configured:

Also see this related thread.

But the apps on the server will create separate directories inside that state directory.

You could use session$doBookmark() to once force the creation of the bookmark directory and read it back in using the onBookmark callback. After this delete the dummy bookmark.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.