Skip to main content

LocalStorageAdapter

Experimental Alpha

LocalStorageAdapter defines the interface for local file storage operations. Implementations handle file I/O, directory management, and storage initialization.

This is currently experimental and may change without a major version bump.

Extended by​

Methods​

clear()​

clear(): Promise<void>;

Alpha

Clears all files in the storage.

Returns​

Promise<void>


deleteFile()​

deleteFile(filePath): Promise<void>;

Alpha

Deletes the file at the given path.

Parameters​

ParameterTypeDescription
filePathstringPath where the file is stored

Returns​

Promise<void>


fileExists()​

fileExists(filePath): Promise<boolean>;

Alpha

Checks if a file exists at the given path.

Parameters​

ParameterTypeDescription
filePathstringPath where the file is stored

Returns​

Promise<boolean>

True if the file exists, false otherwise


getLocalUri()​

getLocalUri(filename): string;

Alpha

Returns the file path for the provided filename in the storage directory.

Parameters​

ParameterTypeDescription
filenamestringThe filename to get the path for

Returns​

string

The full file path


initialize()​

initialize(): Promise<void>;

Alpha

Initializes the storage adapter (e.g., creating necessary directories).

Returns​

Promise<void>


makeDir()​

makeDir(path): Promise<void>;

Alpha

Creates a directory at the specified path.

Parameters​

ParameterTypeDescription
pathstringThe full path to the directory

Returns​

Promise<void>


readFile()​

readFile(filePath): Promise<ArrayBuffer>;

Alpha

Retrieves file data as an ArrayBuffer.

Parameters​

ParameterTypeDescription
filePathstringPath where the file is stored

Returns​

Promise<ArrayBuffer>

ArrayBuffer containing the file data


rmDir()​

rmDir(path): Promise<void>;

Alpha

Removes a directory at the specified path.

Parameters​

ParameterTypeDescription
pathstringThe full path to the directory

Returns​

Promise<void>


saveFile()​

saveFile(filePath, data): Promise<number>;

Alpha

Saves data to a local file.

Parameters​

ParameterTypeDescription
filePathstringPath where the file will be stored
dataAttachmentDataData to store (ArrayBuffer, Blob, or string)

Returns​

Promise<number>

Number of bytes written