I have an AWS bucket with a bunch of dynamically generated JSON files. When a file is generated it gets a "slug".
I'd like to be able to copy that slug (from an outside website) and enter it in a Shiny textInput box, then add the rest of the URL to the slug, and download the designated file as an R object. (I use jsonlite::fromJSON here).
The code below works, and it generates the correct string and puts it into a box in the ui side. But I can't figure out how to use that output variable on the server side. It is hard-coding the "slug". I want to use the slug from the ui textInput.
library(tidyverse)
library(igraph)
library(jsonlite)
library(circlize)
library(chorddiag)
library(plotly)
library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(shinyjs)
ui <- dashboardPage(
dashboardHeader(title = ""),
dashboardSidebar(
textInput("slug","Discovery ID",placeholder = "N79og8K"),
fluidRow(box(textOutput("URL")))
)
)
server <- function(input, output) {
# raw_data_URL <- "https://XXX.s3.us-west-1.amazonaws.com"
# raw_data_suffix <- ".json"
#
# full_URL <- eventReactive(input$submit, {
# paste0(raw_data_URL,"/",input$slug,raw_data_suffix)
# })
# output$URL <- renderPrint(full_URL())
data <- fromJSON(paste0(raw_data_URL,"/","N79og8K",raw_data_suffix))
)
}
I've tried all sorts of things with reactive objects, and haven't gotten anything to work.
Also, the commented out text does work too: it populates the box with the right string on "submit". But I can't get the server to go to the resulting file URL.
Can I use the output variable in my server app?