Working With Files
Once a user is authenticated with the server, they can access their own files. The file operations available to them can be accessed by looking at the server's API documentation at /api/docs, under the "Files" category.
Listening for Folder Updates
We need a way for the client to know when a folder has been updated so that it can refresh its local view. A client can listen for these changes by making a WebSocket connection to /api/files/listen.
Connecting
Like with all file operations, this request needs to be authenticated. See the WebSocket PoP token generation process.
Listening
Once connected, the client should listen for any messages from the server. A message from the server describes the path of the folder that was updated, relative to the user's root directory. Here are some examples.
- If the subfolder
subwas updated, the messagesubwill be sent to the user. - If the subfolder
sub/sub2was updated, the messagesub/sub2will be sent to the user. - If the root folder was updated, the message
.will be sent to the user.
If encrypted is true, messages will be sent in the Excalibur Encryption Format (ExEF). Do remember to decrypt the messages using the master key.
Any messages sent from the client will be ignored.
Remember to close the WebSocket connection when the user logs out or disconnects.