Skip to contents

Loads a file associated with a user from the configured storage backend. The backend is determined by the `ACCOUNT_BACKEND` environment variable (default is `"file"` for local storage), and supports loading various file types like `.Rds`, `.json`, and `.csv` via the appropriate plugin.

Usage

load_user_file(user_id, file_name = "account_tree.Rds")

Arguments

user_id

A string representing the unique user ID.

file_name

The name of the file to load (e.g., `"account_tree.Rds"`). This should be a base name relative to the user-specific storage root.

Value

The R object loaded from the specified file.

Details

This function provides a unified interface to load user-specific data, regardless of where or how it is stored (e.g., local file system, cloud, or database). The actual loading logic is delegated to a plugin based on the backend, which is configured using environment variables.

The function constructs the appropriate arguments for the selected backend using `build_plugin_args()` and dispatches the call using `do.call()`. The file type determines how the file is parsed (e.g., `.Rds` via `readRDS()`, `.json` via `jsonlite::fromJSON()`).

See also

[save_user_file()], [build_plugin_args()], and plugin implementations like `load_from_file()`.

Examples

if (FALSE) { # \dontrun{
Sys.setenv(ACCOUNT_BACKEND = "file")
load_user_file("user123", "account_tree.Rds")
load_user_file("user123", "transactions.csv")
} # }