Skip to main content

NodeFileSystemAdapter

NodeFileSystemAdapter implements LocalStorageAdapter using Node.js filesystem. Suitable for Node.js environments and Electron applications.

Implements

Constructors

Constructor

new NodeFileSystemAdapter(storageDirectory?): NodeFileSystemAdapter;

Parameters

ParameterTypeDefault value
storageDirectorystring'./user_data'

Returns

NodeFileSystemAdapter

Methods

clear()

clear(): Promise<void>;

Clears all files in the storage.

Returns

Promise<void>

Implementation of

StreamingLocalStorageAdapter.clear


createTransportAdapter()

createTransportAdapter(options): AttachmentTransportAdapter;

Creates a streaming transport that transfers bytes between local files and remote storage without materializing them in the JS heap.

Parameters

ParameterType
optionsNodeFileSystemTransportAdapterOptions

Returns

AttachmentTransportAdapter


deleteFile()

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

Deletes the file at the given path.

Parameters

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

Returns

Promise<void>

Implementation of

StreamingLocalStorageAdapter.deleteFile


downloadFile()

downloadFile(filePath): Promise<Blob>;

Parameters

ParameterType
filePathstring

Returns

Promise<Blob>


fileExists()

fileExists(filePath): Promise<boolean>;

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

Implementation of

StreamingLocalStorageAdapter.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

StreamingLocalStorageAdapter.getLocalUri


initialize()

initialize(): Promise<void>;

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

Returns

Promise<void>

Implementation of

StreamingLocalStorageAdapter.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

StreamingLocalStorageAdapter.makeDir


moveFile()

moveFile(sourceUri, targetUri): Promise<number>;

Moves a file into managed storage without loading it into memory. Overwrites any existing file at the target. When source and target are the same path, this is a no-op that just reports the size.

Parameters

ParameterTypeDescription
sourceUristringPath of the existing file
targetUristringDestination path within managed storage

Returns

Promise<number>

Number of bytes in the moved file

Implementation of

StreamingLocalStorageAdapter.moveFile


readFile()

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

Retrieves file data as an ArrayBuffer.

Parameters

ParameterTypeDescription
filePathstringPath 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

StreamingLocalStorageAdapter.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

StreamingLocalStorageAdapter.rmDir


saveFile()

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

Saves data to a local file.

Parameters

ParameterTypeDescription
filePathstringPath where the file will be stored
dataAttachmentDataData 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

StreamingLocalStorageAdapter.saveFile


uploadFile()

uploadFile(
filePath,
data,
options?): Promise<void>;

Parameters

ParameterType
filePathstring
dataArrayBuffer
options?{ encoding: EncodingType; }
options.encoding?EncodingType

Returns

Promise<void>