0

I have a Shiny App where a file is downloaded and further processed. Now I need a way to save the file under the current user in the download directory.

I tried it with classic syntax and already with this version:

How do I set the file path to the current user?

output_file <- "myresults.csv"

Here I would need the path of the current user before the file, because the APP should run over a Shiny server and is used by several users.

Timothy_Goodman
  • 393
  • 1
  • 5
  • 18
  • 2
    The current user of the web front or the server? – doctorlove May 21 '19 at 14:25
  • Did you really load `rpy` or `reticulate` just to try a python solution in an R shiny environment? – r2evans May 21 '19 at 14:41
  • Depending on where it is being served, the R shiny process might be sandboxed enough so that your app cannot get to the user's directory. If you mean a sub-directory of the app specific for that user, then I'd think `dir.create(d <- file.path("cache", thisuser)) ; output_file <- file.path(d, "myresults.csv")` could work. – r2evans May 21 '19 at 14:42
  • No i didnt load rpy or reticulate. I just thought that there is a similar solution in R. – Timothy_Goodman May 21 '19 at 15:12
  • When I use the Windows Path like: c:/UserX/Downloads/myresults.csv it works. But I Need Flexible variable for the user that I can use the App with the shiny server. – Timothy_Goodman May 21 '19 at 15:20
  • A shiny app is meant to be run in a browser. A server can't directly write to a file on the user's computer in a particular folder through the browser. Generally files just to do the "downloads" folder now a days. It's unclear to when exactly where you plan to write files. It would be better if you gave some sort of [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with code that makes it more clear what exactly you are trying to do. – MrFlick May 21 '19 at 15:46

1 Answers1

0

Okay, thanks for the info, Mr Flick. Now I have solved it that I save the file temporarily on the server and the file can be downloaded afterwards.

Timothy_Goodman
  • 393
  • 1
  • 5
  • 18