@createlumina/file-transfer
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Download Core

Version made for Lumina projects. Original credits goes to Voxelum/minecraft-launcher-core-node

npm version Downloads Install size npm Build Status

Provide a high performance download file function based on undici.

  • Support download by range request
    • Customize the range size
  • Support validating the checksum
    • If the validation matched, it won't download the file.
    • Also support customize validation.
  • Support download and fallback to another url
  • Support AbortSignal
  • Fully customizable retry logic

Usage

Download the file by url

import { download } from '@createlumina/file-transfer';

await download({
    url: 'http://example.com/file.zip', // required
    destination: 'file.zip', // required
    headers: {
        // optional
        customized: 'header',
    },
    abortSignal: new AbortController().signal, // optional
    progressController: (url, chunkSize, progress, total) => {
        // optional
        console.log(url);
        console.log(chunkSize);
        console.log(progress);
        console.log(total);
    },
    // use validator to validate the file
    validator: {
        // optional
        algorithm: 'sha1',
        hash: '1234567890abcdef1234567890abcdef12345678',
    },
});

Download with fallback url

import { download } from '@createlumina/file-transfer';

await download({
    // using array to fallback
    url: ['http://example.com/file.zip', 'http://example.com/fallback.zip'],
    destination: 'file.zip',
});

Package Sidebar

Install

npm i @createlumina/file-transfer

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

193 kB

Total Files

44

Last publish

Collaborators

  • padowyt2