Hello. I have a shiny app that downloads a gt table result that is saved using gtsave(). A snippet of the download code is shown below. The code works on my local machine on the browser, but when I publish it to my shinyapps.io site the download fails, and in my Chrome downloads tab I see: "downloads.htm" and then in red underneath it says "Site wasn't available". The download only fails for gtsave() and not for ggsave(), as indicated in the snippet below:
output$download <- downloadHandler(
#Note: result() is the output of an eventReactive call. It returns a list with the properties needed by the
#following code
filename = result()$down_file,
content = function(file) {
output_type <- prep_get_function_output(input$tool_name)
if (output_type == "plot") {
#this works on shinyapps.io. Note that result()$plot is a ggplot object
ggsave(file, result()$plot,
width = result()$width, height = result()$height)
} else if (output_type == "gt_table") {
#this does not work on shinyapps.io, but it works on local host
# note that result()$gt_table is a gt table object
gtsave(result()$gt_table, file)
} else if (output_type == "table") {
}
}
)
I am not including the code of the eventReactive call to get 'result()' because it is long and calls some dependent functions, but I am relatively sure the problem is not there because it is working fine on my local server.
Just a clarification on the above. After posting my question I checked the logs for this app and saw an error that prompted me to include the "webshot2" package. I then did this, but the error persists. I see this on my app logs on shinyapps.io:
2023-10-26T05:26:27.479062+00:00 shinyapps[10301850]: `google-chrome` and `chromium-browser` were not found. Try setting the CHROMOTE_CHROME environment variable or adding one of these executables to your PATH.
2023-10-26T05:26:27.483524+00:00 shinyapps[10301850]: Warning: Error in initialize: Invalid path to Chrome
As explained in the above link and as suggested by my error logs, the problem is that shinyapps.io does not install Chromium or the necessary files associated with Chrome. The link above shows how to solve this.