Deployed Shiny app can't access data folder?

Hi,

We're running a simply Shiny app on Posit Connect. It has built-in functionality when a button is clicked to check a particular folder (NOT within the project directory, it's on a separate server) for data, load that data and then run analysis on it. This works fine when running the app from RStudio IDE, but when published to Posit Connect the app can't find the folder/data. My guess it that Posit Connect doesn't recognize the path I'm referring to since it's now running on the Posit Connect Server. What's the easiest way to tackle this?

https://solutions.posit.co/connections/deploying-data/index.html

The admin guide explains in more detail why this is happening, but as you've seen, relative path traversal isn't going to work. If you can put the relevant files in blob storage or a database that's ideal, but some other strategies are outlined in the article linked above.

1 Like

Hi David,

Thanks for the reply. The path is absolute; actually. It refers to a folder on a specific drive we have. Does this change anything?

It's a no go to put this in a database or blob storage; they're just some flat CSV files that are updated twice per year.

My guess is that I should then include the data within the directory of the app itself? Or that won't work?

Instead of using absolute paths that reference specific locations on your local machine, use relative paths within your Shiny app code. Relative paths are relative to the directory where the app is deployed, making them more portable across different environments.

Hi Stephen,

Are you suggesting to move the data WITHIN the project folder? Because right now it's stored on another server, where end-users save the data to be used by the app.

In our case we can request specific network drives/folders to be mounted on the Posit Connect server. We can then refer to that mounted folder to load data or some other stuff. For example, /mnt/<directory>/data.parquet.

The path to the directory with the data is usually added as an environment variable to the app. This way it can point to different locations on the development environment and on the Posit Connect server.