Why a collaborator cannot delete a document I uploaded onto RStudio Connect

Server:

function(input,output,session){
  
  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 = "api key")
      
      bnd <- bundle_static(input$file$datapath)
      
      content_1 <- deploy(client,bnd,title = paste0(input$pubname, " - ", input$pubmonth, " ", input$pubyear),access_type = "logged_in")
      
      all_users <- get_users(client,limit = 200)
      
      one_user <- all_users %>% filter(username == input$username)
      
      one_user_guid <- one_user %>% pull(guid)
      
      content_1 %>%
        
        acl_add_collaborator(
          one_user_guid
        )
      
      myapp <- set_content_tag_tree(content_1,"tag_tree",input$unitname, input$pubname, input$pubyear, input$pubmonth)
      
      #myapp <- deploy(client, bnd, name = tempdir(),input$pubname," - ",input$pubdate,title = paste0(input$pubname, " - ", input$pubdate))
      
      
      #acl_add_viewer(myapp,"Anyone")
      
      
      poll_task(myapp)
      
      browse_dashboard(myapp)
      
      
      
      
      
    }
  }
  )
  
}

This is an add that I built that allows my team members to upload there documents to RStudio Connect, and they they are added as collaborators of the document that they upload.

My question is around the type of functions these collaborators have access to on RStudio Connect.

Why are they not able to delete a document that they uploaded? But they are a collaborator of the document.

Hi @zuki! We are glad to hear this API process is working for you! Any feedback you have on the process or on what privileges it would be ideal to pass along to your users would be great for us to have as we continue to improve the product!

This is a great example - the ability to "delete" the content is reserved for the owner of the content (you) and administrators on the server. This is a safeguard, so that a collaborator cannot "go rogue" and delete content that they are not the owner of.

However, I can also see how this would be a confusing delineation! The collaborator and owner are very similar for most privilege (access to change parameters on reports, set tags, look at logs, deploy new versions, etc.). However, there are exceptions (like deleting content), and at one point there were limitations on whether collaborators could receive email updates (on failure) or view the usage data for an application. Those may or may not still exist... I know there has been discussion on removing those restrictions for collaborators.

On the "delete" topic, one option would be to have a "to_delete" tag that users could mark content with. I realize that is much less than ideal, but it would make it easier for you to follow up (either manually or programmatically) to delete content that needs to be cleaned up.

I hope that helps!! We will definitely share this feedback with our team!

Actually, one other option that just shipped in the latest version of RStudio Connect (1.8.6) - you can change the owner of content if you are an administrator on the server!! This might be a good solution for your case.

This is not exposed directly in the connectapi package (yet), but you would basically do something like:

content_1$update(owner_guid = "new_owner_guid")

(where new_owner_guid is the user's actual guid).

Do I have to type in the actual user's guid?

When I do this, I get an error:

content_1$update(owner_guid  = one_user_guid)

where the one_user_guid comes from:

all_users <- get_users(client,page_size = 20,prefix = NULL,limit = 200)
      
      one_user <- all_users %>% filter(username == input$username)
      
      one_user_guid <- one_user %>% pull(guid)

Is it possible to share the error message that you're getting?

Thank you I managed to fix the error.

But the problem is still there, users are still not able to delete the content that they have upload. Here is my code:

server <- 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,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 == input$username)
      
      one_user_guid <- one_user %>% pull(guid)
      
      content_1$update(owner_guid  = one_user_guid)
      
      content_1 %>%
        
        acl_add_collaborator(
          one_user_guid
        )
      
      
      myapp <- set_content_tag_tree(content_1,"Tags",input$unitname, input$pubname, input$pubyear, input$pubmonth)
      
      #myapp <- deploy(client, bnd, name = tempdir(),input$pubname," - ",input$pubdate,title = paste0(input$pubname, " - ", input$pubdate))
      
      
      
      poll_task(myapp)
      
      browse_dashboard(myapp)
      
      
      
     
      }
    }
    )
  
}
shinyApp(ui = ui, server = server)

So sorry for the delay getting back to you here!!

In sum, you are right! The $update(owner_guid = ...) function needed to be ported to the newer version of the API. It also requires RStudio Connect 1.8.6. If you update to the newest version of the connectapi package (0.1.0.9018 at the time of writing) and ensure you are running RStudio Connect version 1.8.6 (latest patch release is 1.8.6.2), then this function should work now!

Please let us know if you run into any more trouble!! Hopefully this will fix your issue!