Skip to main content

IndexDBFileSystemStorageAdapter

IndexDBFileSystemStorageAdapter implements LocalStorageAdapter using IndexedDB. Suitable for web browsers and web-based environments.

Implements

Constructors

Constructor

new IndexDBFileSystemStorageAdapter(databaseName?): IndexDBFileSystemStorageAdapter;

Parameters

ParameterTypeDefault value
databaseNamestring'PowerSyncFiles'

Returns

IndexDBFileSystemStorageAdapter

Methods

clear()

clear(): Promise<void>;

Clears all files in the storage.

Returns

Promise<void>

Implementation of

LocalStorageAdapter.clear


deleteFile()

deleteFile(uri, options?): Promise<void>;

Deletes the file at the given path.

Parameters

ParameterType
uristring
options?{ filename?: string; }
options.filename?string

Returns

Promise<void>

Implementation of

LocalStorageAdapter.deleteFile


fileExists()

fileExists(fileUri): Promise<boolean>;

Checks if a file exists at the given path.

Parameters

ParameterType
fileUristring

Returns

Promise<boolean>

True if the file exists, false otherwise

Implementation of

LocalStorageAdapter.fileExists


getLocalUri()

getLocalUri(filename): string;

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

Implementation of

LocalStorageAdapter.getLocalUri


initialize()

initialize(): Promise<void>;

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

Returns

Promise<void>

Implementation of

LocalStorageAdapter.initialize


makeDir()

makeDir(path): Promise<void>;

Creates a directory at the specified path.

Parameters

ParameterTypeDescription
pathstringThe full path to the directory

Returns

Promise<void>

Implementation of

LocalStorageAdapter.makeDir


readFile()

readFile(fileUri, options?): Promise<ArrayBuffer>;

Retrieves file data as an ArrayBuffer.

Parameters

ParameterType
fileUristring
options?{ encoding?: EncodingType; mediaType?: string; }
options.encoding?EncodingType
options.mediaType?string

Returns

Promise<ArrayBuffer>

ArrayBuffer containing the file data

Implementation of

LocalStorageAdapter.readFile


rmDir()

rmDir(path): Promise<void>;

Removes a directory at the specified path.

Parameters

ParameterTypeDescription
pathstringThe full path to the directory

Returns

Promise<void>

Implementation of

LocalStorageAdapter.rmDir


saveFile()

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

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

Implementation of

LocalStorageAdapter.saveFile