Closed genobobeno closed 4 years ago
Hey,
the add_resources_path() is used for the UI elements, for example if you need to do tags$img(src = "www/plop.png")
. What is done with add_resource_path is attaching a folder as a resources to the web browser, so R has no access to that per se.
If you want to refer to file from inside the app for the server computation, you can access files in www
using the app_sys()
function, which comes by default with all golem > 0.2.0 apps.
So app_sys("plop.rds")
refers to inst/plop.rds
.
Finally, piece of advice, if you are reading Rds files that stay the same in the app, I'd suggest using the package data format http://r-pkgs.had.co.nz/data.html
Let me know if that helps.
Cheers, Colin
@genobobeno Have you tried my solution?
Cheers, Colin
I got it working with system.file("myfile",package="MyGolemPackage") ...which it looks like app_sys() wraps to. Things are working.
Hello, I am trying to read simple *.rds files from the www directory after running the default add_resource_path and golem_add_external_resources() in app_ui.R
My functions are telling me the files in "www" don't exist. I tried a simple print(dir("")), print(dir("www")) function in app_server.R to test the issue. They're returning character(0)'s. I don't understand how these resources are shared throughout the app... and it definitely doesn't feel intuitive. Can't tell if it's a bug or I'm just an idiot.