Score
0
Watch 7 Star 27 Fork 5

水熊宝宝 / fast-downNodeJSBSD-3-Clause

Join us
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
nodejs 大文件分片下载工具,使用进程process的方式分片下载,文件合并使用filestream,不受nodejs单进程的内存限制可以下载较大的文件,支持断点续传。 spread retract

Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

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
        });

        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');
})();

Comments ( 0 )

Sign in for post a comment

NodeJS
1
https://gitee.com/dreamidea/fast-down.git
git@gitee.com:dreamidea/fast-down.git
dreamidea
fast-down
fast-down
master

Help Search