Skip to content

fs

Lite filesystem access is host-mediated. Space-wide reads require workspace.files; writes also require contribution write access. Text reads are limited to 2 MiB; binary I/O to 16 MiB. getUrl streams media. Direct mutation of an open working copy fails with BUSY; rename rejects existing targets with ALREADY_EXISTS.

Usage guide: files. API index.

Signatures, parameters and return types are generated from the SDK. Optional members are not available in every host and context.

Source

Supported hosts: Lite Mobile

Read file text, up to 2 MiB.

readText(path: string): Promise<string>;
Parameter Type Required
path string Yes

Returns: Promise<string>.

Supported hosts: Lite Mobile

Write text, creating parent directories when needed.

writeText(path: string, content: string): Promise<void>;
Parameter Type Required
path string Yes
content string Yes

Returns: Promise<void>.

Supported hosts: Lite Mobile

Read file bytes, up to 16 MiB.

readBinary(path: string): Promise<Uint8Array>;
Parameter Type Required
path string Yes

Returns: Promise<Uint8Array>.

Supported hosts: Lite

Write file bytes, up to 16 MiB.

writeBinary(path: string, content: Uint8Array): Promise<void>;
Parameter Type Required
path string Yes
content Uint8Array Yes

Returns: Promise<void>.

Supported hosts: Lite

Delete a permitted file. Open working copies are protected with BUSY.

delete(path: string): Promise<void>;
Parameter Type Required
path string Yes

Returns: Promise<void>.

Supported hosts: Lite

Move a regular file within the Space. Existing targets fail with ALREADY_EXISTS.

rename(oldPath: string, newPath: string): Promise<void>;
Parameter Type Required
oldPath string Yes
newPath string Yes

Returns: Promise<void>.

Supported hosts: Lite Mobile

List permitted files; defaults to recursive, file-only listing. Use includeDirectories for directory trees.

list(folder?: string, options?: FileListOptions): Promise<FileStat[]>;
Parameter Type Required
folder string No
options FileListOptions No

Returns: Promise<FileStat[]>.

Supported hosts: Lite Mobile

Read file metadata; return null if the file is absent.

stat(path: string): Promise<FileStat | null>;
Parameter Type Required
path string Yes

Returns: Promise<FileStat &#124; null>.

Supported hosts: Lite

Get a streaming media URL; omitting path uses the bound file where supported.

getUrl(path?: string): Promise<string>;
Parameter Type Required
path string No

Returns: Promise<string>.

Supported hosts: Lite Mobile

Subscribe to file or directory changes. Release the returned subscription when finished.

watch(pathOrFolder: string, listener: () => void): Promise<Disposable>;
Parameter Type Required
pathOrFolder string Yes
listener () => void Yes

Returns: Promise<Disposable>.

Related types: FileListOptions, FileStat, Disposable.