Using www folder: Save and display pdf



I have a shiny app where the user selects an item (there are multiple items to choose from), then a pdf from a private Amazon S3 bucket is saved, and the saved pdf is shown to the user via an iframe.

code within server to get pdf, write it to www, and display it to the user:

output$test_result <- renderUI({
test_result() %>%
          str_replace("", "s3:/") %>%
          get_object() %>%
        tags$iframe(style = "height:1400px; width:100%", src = "test_result.pdf")

A download button is displayed and the user can download the pdf file if they want

  output$download_test_results <- downloadHandler(
    filename = function() {
    content = function(file) {
      file.copy("www/test_result.pdf", file)

I'm confused about how this will work with multiple users. Let's say user 1 selects item 1 and the pdf (test_result.pdf) is written to the www folder. What if another user (user 2) is using the app at the same time and selects item 2, which writes a pdf (the pdf is different but will still have the name "test_result.pdf") to the www folder. Is there a separate www folder for each user session and therefore multiple users can't impact each other's sessions? Or will user 2's selection impact user 1?

Is the www folder the right place to save files? Once the user's session ends, the files can be deleted.


Could you please add code formatting? It just makes the text much more readable, and makes easier for others to help you out! :+1:

Here's our FAQ on how to do so: