Where do Files Write on Shiny Server

I can write files when running my app locally, they go to my working directory as expected. However, when I publish to the server and run the same code I can't find where the files are writing to even when I specify a working directory.. Probably a novice question, but the behavior is not clear. My code is simple:

write.table(results, file = input$fileName2, sep = ",")

I'm writing a dataframe named as specified in the UI. The server log does not provide any transactional info. Anyone have ideas on what I can check?

Im confused reading this because you say that you specified a working directory, and that you wrote out a file to it. The logs are clear, I.e. no failure message, so I must assume the file got written to the path you specified.

You say you cant find the file,... and well... maybe I'm being pedantic, so please forgive me in advance, but you didn't write that you looked in the working directory you specified and that it was empty... can you confirm that you've done that?

Oh, shinyapps.io isn't mentioned in your post, but it is in a tag... do you mean that you are using the shinyapps.io platform. Its not your personal server so you can't have full access to it. You should use tempdir() to get a temporary path and write files to that. For permanent storage you should look into options such as an external database or storage hosting service. Or for tactical purposes you could have a download button in your shinyapp that client can use to download file(s) to their client machines.

Yes, I'm new to shiny and my use case is to provide a relatively simple application at no charge to my industry which demonstrates fundamentals of machine learning. So, I have a fully functional app on my pc and now I want to publish this and make it available to a targeted group of practitioners. I intend to purchase the shiny pro version of the shiny.io platform, but before I do this I want to make sure the data flow works. I know how to connect to databases but don't think this is required for this use case since the data sets are relatively small.

The design is to have the user upload an .xlsx of their data (I have this working on the server) and shapefiles (I'm still working on this based on your previous suggestion). The user then performs actions on this data, and I want them to be able to save this data for later use in the process. Reactivity is not used in this case (i.e. saving the data set in memory for the instance) because there may be several versions of this data set. I'd prefer to keep the data on the shiny.io server platform for performance purposes, rather than the user continuously downloading and uploading files on their pc.

It looks like there are 2 main options for my use case. I can figure out how to access uploaded and saved files thru tempdir() functions, or have them upload, download, upload processes (less optimal). To be clear, my local app on my pc works fine and it's understood where files go based on my working directory. What I don't understand is where files go on the shiny.io server platform, how I can fetch them, rename them and give the user an option to copy or download them on to their pc for later use if they choose. It'd be great if there was a vignette or example I could follow for what appears to be a novice request.

I decided to use this structure to allow the user to save results at their choosing. This is simple and works:

output$Results <- downloadHandler(
filename = function() {
paste(filename)
},
content = function(file) {
write.table(Results, file, row.names = FALSE, sep = ",")
}
)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.