GithubHelp home page GithubHelp logo

Is there a way to make (force?) rappdirs::user_data_dir()to point to a local directory when app is deployed on Posit Connect? about rappdirs HOT 5 CLOSED

r-lib avatar r-lib commented on June 18, 2024
Is there a way to make (force?) rappdirs::user_data_dir()to point to a local directory when app is deployed on Posit Connect?

from rappdirs.

Comments (5)

gaborcsardi avatar gaborcsardi commented on June 18, 2024 1

I don't really understand this. You cannot save a file in the user's machine if they are using your app through a web browser. You can offer them a file to download, but you cannot specify where it is saved. But maybe I am misunderstanding something.

from rappdirs.

Shelmith-Kariuki avatar Shelmith-Kariuki commented on June 18, 2024 1

No. Exactly that. I thought it was possible. Thanks a lot. I'll look for an alternative

from rappdirs.

gaborcsardi avatar gaborcsardi commented on June 18, 2024

Now when we deploy the app to Posit Connect, rappdirs::user_data_dir() registers a dir on the posit connect server such that another user can load that saved input file.

Are you sure about this?

Aren't Connect deployments isolated from each other?

Also, what is that location? I think the Connect server runs on Linux, where the default data directory should be inside your home directory. E.g. for me:

> rappdirs::user_data_dir()
[1] "~/.local/share"

In any case, rappdirs follows the XDG spec (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), so you can set the XDG_DATA_HOME env var to the desired location:

> Sys.setenv("XDG_DATA_HOME" = "/tmp/")
> rappdirs::user_data_dir()
[1] "/tmp/"

from rappdirs.

Shelmith-Kariuki avatar Shelmith-Kariuki commented on June 18, 2024

@gaborcsardi ,

We are using the function to save an input file locally on people's machines, even though they are viewing a live deployed app. It's as though the file is being saved on the Connect server.

from rappdirs.

gaborcsardi avatar gaborcsardi commented on June 18, 2024

If you want to store some (small amount of) data on the user's machine, then you can use cookies:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
There is also an R package for that:
https://r4ds.github.io/cookies/
(I haven't tried it, so this is not an endorsement.)

from rappdirs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.