Hello,
I am trying to get the URL of the content that I have uploaded to RStudio Connect using an app I created in shiny.
I want to use the get_vanity_url function to get the url for the the content that was just uploaded, I tried using the get_vanity_url function by I get an error, not sure if I am not using the function correctly?
Here is my code:
function(input, output){
observeEvent(input$upload, {
require(input$file)
file <- file.copy(from = input$file$datapath,
to = paste0(tempdir(),input$pubname,
" - ",
input$pubmonth,
" ",
input$pubyear,
".pdf"))
if(!is.null(input$file)){
#readRenviron("~/rstudio/connectapi/.Renviron.alt")
client <- connect(host = "server",
api_key = "key"
)
bnd <- bundle_static(path = input$file$datapath)
content_1 <- deploy(client,bnd,name = connectapi ::: create_random_name(length = 50),title = paste0(input$pubname, " - ", input$pubmonth, " ", input$pubyear), access_type = "logged_in")
all_users <- get_users(client,page_size = 20,prefix = NULL,limit = 200)
one_user <- all_users %>% filter(username == toupper(input$username))
one_user_guid <- one_user %>% pull(guid)
content_1 %>%
acl_add_collaborator(
one_user_guid
)
myapp <- set_content_tag_tree(content_1,"Reports",input$unitname, input$pubname, input$pubyear, input$pubmonth)
#myapp <- deploy(client, bnd, name = tempdir(),input$pubname," - ",input$pubdate,title = paste0(input$pubname, " - ", input$pubdate))
content_1$update(owner_guid = one_user_guid)
if(input$upload == TRUE) {
showModal(modalDialog("Report Uploaded"))
get_vanity_url(client, content_1)
# poll_task(myapp)
# browse_dashboard(myapp)
} else {
showModal(modalDialog("Error in uploading report"))
}
}
}
)
}
I then want the app to email this URL to the owner of this content, is this possible?
Would really appreciate some assistance