1

I know how to use tags$iframe with src pointing to my pdf or jpeg file located in my www folder like this question explains: displaying a pdf from a local drive in shiny

My problem, however, is that I do not want to make the files publicly accessible through the www folder. To avoid this, I have tried using imageOutput() and renderImage() and gotten picture files to work reasonably-well.

My issue still remains with the pdfs which do not load using imageOutput. How can I embed a pdf in my shiny-app without making it publicly available in the www folder. Ideally, this solution would also work with jpeg and other picture files as well.

The iframe solution is perfect except for its publicly available www folder

road_to_quantdom
  • 1,341
  • 1
  • 13
  • 20
  • Depending on which part of your file system is not public, you could add it with `addResourcePath()`: https://shiny.rstudio.com/reference/shiny/1.0.1/addResourcePath.html? – Tonio Liebrand Jun 25 '19 at 08:47
  • `When pages are loaded with a HTTP(S) protocol (the case of the Shiny app) for security reasons you can't framed locals files with their file: URLs.` I see this a lot. Would using `addResourcePath()` avoid these security reasons? Sorry I'm not very familiar with all of this – road_to_quantdom Jun 25 '19 at 11:26
  • I used `addResourcePath()` and it worked. but there still seems to be a URL that anyone can access without going through my app's password UI. Mainly by just typing in: `mywebsite.com/new_path/path_to_file.pdf` – road_to_quantdom Jun 25 '19 at 13:25
  • i am not an expert in website security, but i would attempt creating a directory where undesired access is blocked (https://stackoverflow.com/questions/19128068/deny-access-to-website-folders) and then use this directory as a resource path,.. – Tonio Liebrand Jun 25 '19 at 13:39

0 Answers0