UNPKG

1.04 kBTypeScriptView Raw
1declare const _default: (sourceUrl: string, targetFile: string, progressCallback?: ByteProgressCallback | undefined, length?: number | undefined) => Promise<void>;
2/**
3 * Public: Download a file and store it on a file system using streaming with appropriate progress callback.
4 *
5 * @param sourceUrl Url to download from.
6 * @param targetFile File path to save to.
7 * @param progressCallback Callback function that will be given a {ByteProgressCallback} object containing both
8 * bytesDone and percent.
9 * @param length File length in bytes if you want percentage progress indication and the server is unable to provide a
10 * Content-Length header and whitelist CORS access via a `Access-Control-Expose-Headers "content-length"` header.
11 * @returns A {Promise} that will accept when complete.
12 */
13export default _default;
14/** Public: Progress callback function signature indicating the bytesDone and optional percentage when length is known. */
15export declare type ByteProgressCallback = (bytesDone: number, percent?: number) => void;