10 Star 46 Fork 10

Cherokee / fast-down

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
Rorical 提交于 2020-09-07 22:04 . !1增加下载请求时的header头

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');
})();
NodeJS
1
https://gitee.com/dreamidea/fast-down.git
git@gitee.com:dreamidea/fast-down.git
dreamidea
fast-down
fast-down
master

搜索帮助