← 全部工具

ipull

热度 65 更新于 开发与构建

The only file downloader you'll ever need. For node.js and the browser, CLI and library for fast and reliable file downloads.

npmauto-collected

安装

npm
npm install -g ipull

通过 npm 安装。

<div align="center" <h1iPull</h1 <img src="./assets/ipull-logo-rounded.png" height="200px" / </div

<div align="center"

</div <br /

Super fast file downloader with multiple connections

npx ipull http://example.com/file.large

Features

  • Download using parallels connections
  • Maximize download speed (automatic parallelization, 3+)
  • Pausing and resuming downloads
  • Node.js and browser support
  • Smart retry on fail
  • CLI Progress bar
  • Download statistics (speed, time left, etc.)

NodeJS API

import {downloadFile} from 'ipull';

const downloader = await downloadFile({
    url: 'https://example.com/file.large',
    directory: './this/path', // or 'savePath' for full path
    cliProgress: true, // Show progress bar in the CLI (default: false)
    parallelStreams: 3 // Number of parallel connections (default: 3)
});

await downloader.download();

Browser support

Download a file in the browser using multiple connections

import {downloadFileBrowser} from "ipull/dist/browser.js";

const downloader = await downloadFileBrowser({
    url: 'https://example.com/file.large',
    acceptRangeIsKnown: true, // overcome CORS, force multi-connection download (use only if you know the server supports range requests)
    // defaultFetchDownloadInfo: { // set download info manually to overcome CORS issues && prevent multiple requests
    //     acceptRange: true,
    //     length: 40789822,
    // }
});

await downloader.download();

console.log(downloader.writeStream.result); // Uint8Array


### Custom stream

You can use a custom stream

import {downloadFileBrowser} from "ipull/dist/browser.js";

const downloader = await downloadFileBrowser({ url: 'https://example.com/file.large', onWrite: (cursor: number, buffers: Uint8Array[], options) = { const totalLength = buffers.reduce((acc, buffer) = acc + buffer.length, 0); console.log(Writing ${totalLength} bytes at cursor ${cursor}, with options: ${JSON.stringify(options)}); } });

await downloader.download(); console.log(downloader.writeStream.result.length === 0); // true, because we write to a custom stream