# fast-down **Repository Path**: dreamidea/fast-down ## Basic Information - **Project Name**: fast-down - **Description**: nodejs 大文件分片下载工具,使用进程process的方式分片下载,文件合并使用filestream,不受nodejs单进程的内存限制可以下载较大的文件,支持断点续传。 - **Primary Language**: NodeJS - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 44 - **Forks**: 10 - **Created**: 2018-06-25 - **Last Updated**: 2023-06-13 ## Categories & Tags **Categories**: web-dev-toolkits **Tags**: None ## README # fast-down nodejs 大文件分片下载工具,使用进程process的方式分片下载,文件合并使用filestream,不受nodejs单进程的内存限制可以下载较大的文件。 ## 用法 ## 安装 全局安装 ``` npm install fast-down ``` 如果要全局安装请加上-g参数 全局安装模式下,可以直接当做下载工具使用: ``` fast-down "http://xxx/big-file.zip" big-file.zip 4 ``` 表示4个分片并发下载 在项目中引用: ``` const fast_down = require('fast-down'); (async() => { var url = 'http://bla..../file.mp4'; var filepath = 'filename.mp4'; var con_num = 4; let stime = new Date().getTime(); console.log('start download, concurrency: ' + con_num); var downloader = new fast_down.Downloader(url, filepath, { 'concurrency': con_num, 'progress_throttle': 4000, "headers":{ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36", "Referer":"https://www.bilibili.com/", "Origin": "https://www.bilibili.com" } }); downloader.onProgress((pct, tinfo, pinfo) => { console.log('progress:',pct); }); let ret = await downloader.download(); console.log('download ' + (ret ? 'success' : 'fail') + ', cost: ' + (new Date().getTime() - stime) + 'ms'); })(); ```