'Shiny App not finding PDF file in www folder
I am trying to create a simple button, link, and/or viewing pane in my Shiny App that allows users to download a pre-existing PDF file that I have saved in my www folder (code below). The App keeps coming back with the error message "File not Found". However, when I check that the file exists with file.exists("www/sample_label.pdf") it returns TRUE. I can't for the life of me figure out where the problem is coming from. The code works if I try a url like "https://cran.r-project.org/doc/manuals/r-release/R-intro.pdf". Any help would be greatly appreciated. Thanks
library(shiny)
ui <- fluidPage(
titlePanel("Vaccine Label"),
mainPanel(
downloadButton("downloadLabel", label = "Download Label", class = NULL, icon = shiny::icon("download")),
br(),
tags$a("Download Label", href = "www/sample_label.pdf"),
br(),
tags$iframe(style="height:600px; width:100%; scrolling = yes", src = "www/sample_label.pdf")
)
)
server <- function(input, output) {
output$downloadLabel <- downloadHandler(
filename = "www/sample_label.pdf",
content = function(file) {
file.copy("temp.pdf", file)
}
)
}
shinyApp(ui, server)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
