Hello R and Rshiny Community -
I have this module for downloading images in my R shiny app, which works with one caveat. So if user selects png or tiff download option, then the pasted file name is as expected and it pops up as I would expect in the save file box.However when a user selects pdf, there is a delay, no save as box pops up, and it is automatically rendered in a pdf viewer. Additionally, the pasted name does not work and random letters are placed in front of the pdf (e.g. Rstudio-YXfJIJ.pdf rather than data-10.29.2020.pdf). Additionally, this problem does not happen on a linux or mac but this issue only occurs on windows.
Any thoughts on why
mod_downloadImage_ui <- function(id) {
ns <- NS(id)
tagList(
selectInput(ns("file_type"), label = "File Type",
choices = c("pdf", "png", "tiff")),
downloadButton(ns("downloadPlot"),"Download Plot"))
mod_downloadImage_server <- function(input, output, session, tree_out) {
ns <- session$ns
output$downloadPlot <- downloadHandler(
filename = function(){
paste("data-", Sys.Date(), ".", input$file_type, sep="")},
content = function(file){
ggplot2::ggsave(file, plot=tree_out(),
device = input$file_type)
}
)