NodeFileSystemAdapter
NodeFileSystemAdapter implements LocalStorageAdapter using Node.js filesystem. Suitable for Node.js environments and Electron applications.
Implements
Constructors
Constructor
new NodeFileSystemAdapter(storageDirectory?): NodeFileSystemAdapter;
Parameters
| Parameter | Type | Default value |
|---|---|---|
storageDirectory | string | './user_data' |
Returns
NodeFileSystemAdapter
Methods
clear()
clear(): Promise<void>;
Clears all files in the storage.
Returns
Promise<void>
Implementation of
deleteFile()
deleteFile(path, options?): Promise<void>;
Deletes the file at the given path.
Parameters
| Parameter | Type |
|---|---|
path | string |
options? | { filename?: string; } |
options.filename? | string |
Returns
Promise<void>
Implementation of
LocalStorageAdapter.deleteFile
downloadFile()
downloadFile(filePath): Promise<Blob>;
Parameters
| Parameter | Type |
|---|---|
filePath | string |
Returns
Promise<Blob>
fileExists()
fileExists(filePath): Promise<boolean>;
Checks if a file exists at the given path.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | Path where the file is stored |
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
| Parameter | Type | Description |
|---|---|---|
filename | string | The 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
| Parameter | Type | Description |
|---|---|---|
path | string | The full path to the directory |
Returns
Promise<void>
Implementation of
readFile()
readFile(filePath, options?): Promise<ArrayBuffer>;
Retrieves file data as an ArrayBuffer.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | Path where the file is stored |
options? | { encoding?: EncodingType; mediaType?: string; } | - |
options.encoding? | EncodingType | - |
options.mediaType? | string | - |
Returns
Promise<ArrayBuffer>
ArrayBuffer containing the file data
Implementation of
rmDir()
rmDir(path): Promise<void>;
Removes a directory at the specified path.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | The full path to the directory |
Returns
Promise<void>
Implementation of
saveFile()
saveFile(
filePath,
data,
options?): Promise<number>;
Saves data to a local file.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | Path where the file will be stored |
data | AttachmentData | Data to store (ArrayBuffer, Blob, or string) |
options? | { encoding?: EncodingType; mediaType?: string; } | - |
options.encoding? | EncodingType | - |
options.mediaType? | string | - |
Returns
Promise<number>
Number of bytes written
Implementation of
uploadFile()
uploadFile(
filePath,
data,
options?): Promise<void>;
Parameters
| Parameter | Type |
|---|---|
filePath | string |
data | ArrayBuffer |
options? | { encoding: EncodingType; } |
options.encoding? | EncodingType |
Returns
Promise<void>