Purpose of publicClient

hi,
Please help me understand publicClient concept.

As docs say publicClient is a ‘Helper to read/write to the user’s public directories, e.g. /public/shares.’
I don’t understand what you mean by ‘public’ ? Resources that can be accessed from every apps and anyone ?

Yes, exactly. All documents in the special /public directory can be accessed (GET/HEAD) without authorization. But only single documents with their exact URL can be accessed by anyone, and not the directory listings.

With the correct authorization/token you can also write to /public (or /public/categoryname/), i.e. PUT/DELETE documents, as well as read the directory listings.

In remoteStorage.js modules, the publicClient is just a scoped BaseClient for the public category of the module. So if your module is e.g. documents, the privateClient is scoped to /documents/, while the publicClient is scoped to /public/documents.

Does that make sense to you?

1 Like

ok, thanks for the explanation.
i guess that a document written by app1 cannot be modified by app2.

As long as the app requests access and the user grants it, the app can write to any category it has claimed access to. Different apps accessing the same document is one of the core ideas and main benefits of the remoteStorage protocol.