default
Source: FileWriter.ts:13
Manages file system operations including directory creation, path resolution, and stream persistence.
- Author: Nur Rony<pro.nmrony@gmail.com>
Constructors
new default(destination: string, overwrite: boolean): default
Parameters
destination(string) — The root directory for downloads.overwrite(boolean, default: "false") — Whether to overwrite existing files.
Returns
default
Methods
canWrite(url: string): Promise<boolean>
async
FileWriter.ts:54Verifies if writing is permitted based on the overwrite flag and existing files.
Parameters
url(string) — The URL to check against the file system.
Returns
Promise<boolean>— Returns true if writing should proceed.
getTargetPath(url: string): Promise<string>
async
FileWriter.ts:32Get the target directory path
Parameters
url(string) — The URL to transform.
Returns
Promise<string>— The localized file path.
prepareDirectory(url: string): Promise<string>
async
FileWriter.ts:42Ensures the destination directory exists for a specific URL.
Parameters
url(string) — The URL of the file to be saved.
Returns
Promise<string>— The prepared absolute target path.
saveStream(
webStream: ReadableStream,
filePath: string,
): Promise<void>
async
FileWriter.ts:71Pipes a web-standard ReadableStream to the local file system using stream/promises.
Parameters
webStream(ReadableStream) — The source stream from the network.filePath(string) — The destination path.
Returns
Promise<void>— Resolves when the stream finishes writing.