browFiles
List the files and folders at a given path in the store's file storage.
Import
import { browFiles } from "@evershop/evershop/cms/services";
Syntax
browFiles(path: string): Promise<{ files: FileBrowser[]; folders: string[] }>
Parameters
path
Type: string
The path to list. This is a storage key prefix, not necessarily a local directory — see Storage providers. Leading and trailing slashes are normalised away.
Return Value
Returns Promise with:
{
files: FileBrowser[]; // Array of file objects
folders: string[]; // Array of folder names
}
FileBrowser object:
{
name: string; // File name
url: string; // Public URL of the file
}
url is whatever the active provider considers the file's public URL: a local /assets/... path when storage is local, or the object/CDN URL (the provider's baseUrl when one is configured) when a cloud provider is active.
With the local provider, a path that does not exist throws Requested path does not exist. Cloud providers list by key prefix, so a non-existent prefix simply returns empty arrays.
Storage providers
browFiles resolves the file browser at call time from the fileBrowser registry value, seeded from the active storage provider. The provider is chosen by the fileStorage admin setting, falling back to the system.file_storage config (default local). Core ships local, s3, azure and gcs implementations, and an extension can register its own.
So the same call browses the local media directory on one deployment and an S3 bucket, an Azure container or a GCS bucket on another — the calling code does not change. Treat path as a storage key, not a filesystem path: do not join it with process.cwd(), and do not assume fs can see it.
See Also
- createFolder - Create folder
- uploadFile - Upload files
- deleteFile - Delete files