Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@isdk/ai-tool-downloader
Advanced tools
The Large File Downloader for ServerTools
The current implementation includes the following features:
BaseFileDownload
.FileDownload
class.Features:
config
) to set server parameters or retrieve current settings:
concurrency
: Maximum number of concurrent downloads allowedrootDir
: Root directory where downloaded files will be storedautostartQueue
: Automatically start the next pending task in the queue after a file is completedcleanTempFile
: Whether to remove temporary files upon successful completionautoScaleDownloads
: If concurrency limit is reached, automatically stop an older download or report an errornpm install @isdk/ai-tool-download
or
yarn add @isdk/ai-tool-download
import { AbortErrorCode } from '@isdk/ai-tool'
import { ChunkDownload } from '@isdk/ai-tool-downloader'
const aborter = new AbortController()
const chunk = new ChunkDownload({url: 'http://example.com/file.zip', filepath: '/tmp/file.zip', overwrite: false, index: 0, aborter, timeout:false})
chunk.on('progress', ({percent, totalBytes, transferredBytes}, chunk: Uint8Array) => {
console.log('🚀 ~ onDownloadProgress ~ percent: %', percent, totalBytes, transferredBytes)
})
chunk.on('status', function(status: FileDownloadStatus) {
console.log(status)
})
try {
await chunk.start()
} catch (error) {
if (error.code === AbortErrorCode) {
// the abort signal sended
} else {
throw error
}
}
import { AbortErrorCode } from '@isdk/ai-tool'
import { FileDownload } from '@isdk/ai-tool-downloader'
const aborter = new AbortController()
const download = new FileDownload({url: 'http://example.com/file.zip', filepath: '/tmp/file.zip', overwrite: false, index: 0, aborter, timeout:false})
download.on('progress', ({percent, totalBytes, transferredBytes}, chunk: Uint8Array) => {
console.log('🚀 ~ onDownloadProgress ~ percent: %', percent, totalBytes, transferredBytes)
})
download.on('status', function(status: FileDownloadStatus) {
console.log(status)
})
try {
await download.start()
} catch (error) {
if (error.code === AbortErrorCode) {
// the abort signal sended
} else {
throw error
}
}
Overview:
The ChunkDownload
class is designed for downloading a file in chunks, supporting both single and concurrent block downloads with resuming functionality.
Features:
Usage:
import { AbortErrorCode } from '@isdk/ai-tool'
import { ChunkDownload } from '@isdk/ai-tool-downloader'
const aborter = new AbortController()
const chunk = new ChunkDownload({url: 'http://example.com/file.zip', filepath: '/tmp/file.zip', overwrite: false, index: 0, aborter})
chunk.on('progress', ({percent, totalBytes, transferredBytes}, chunkData) => {
console.log(`Download progress: ${percent}% (${transferredBytes}/${totalBytes} bytes)`)
})
try {
await chunk.start()
} catch (error) {
if (error.code === AbortErrorCode) {
// The abort signal was sent
} else {
throw error
}
}
Configuration:
url
: URL of the file to be downloadedfilepath
: Destination path where the file will be savedoptions.startByte
(optional): Start downloading from a specific byte positionoptions.endByte
(optional): Download up to a certain byte positionoptions.overwrite
(default: false): Overwrite an existing file if it already existsoptions.aborter
(optional): Abort controller for interrupting the downloadEvents:
progress
: Emitted when download progress changes, providing information about the current percentage of completion and transferred bytes.status
: Provides detailed status updates during the download process, including file size, total downloaded bytes, etc.Overview:
The BaseFileDownload
class is an abstract base for multi-block concurrent download of a single file, assuming that the server supports range requests. It creates and manages chunks to efficiently handle large files.
Features:
p-limit
for managing concurrent tasks.Usage:
import { FileDownload } from '@isdk/ai-tool-downloader'
const download = new BaseFileDownload({url: 'http://example.com/file.zip', filepath: '/tmp/file.zip'})
// ...
Configuration:
url
: URL of the file to be downloadedfilepath
(optional): Destination path where the final file will be savedoptions.concurrency
(default: 3): Maximum number of concurrent downloads allowedoptions.chunkSizeInBytes
(default: 64MB): Size for each chunkoptions.destinationFolder
(optional): Custom directory to save the final fileoptions.cleanTempFile
(default: true): Whether to remove temporary files upon successful completionoptions.overwrite
(default: false): Overwrite an existing file if it already existsMethods:
Overview:
The FileDownload
class extends from BaseFileDownload
, providing an asynchronous multi-threaded download process for a single file, assuming that the server supports range requests. It utilizes p-limit
to manage concurrent tasks and efficiently handle large files.
Features:
p-limit
for managing concurrent tasks, with an option to limit the number of threads based on server capacity.Usage:
import { FileDownload } from '@isdk/ai-tool-downloader'
const download = new FileDownload({url: 'http://example.com/file.zip', filepath: '/tmp/file.zip'})
// ...
Configuration:
url
: URL of the file to be downloadedfilepath
(optional): Destination path where the final file will be savedoptions.concurrency
(default: 3): Maximum number of concurrent downloads allowedoptions.chunkSizeInBytes
(default: 64MB): Size for each chunkoptions.destinationFolder
(optional): Custom directory to save the final fileoptions.cleanTempFile
(default: true): Whether to remove temporary files upon successful completionoptions.overwrite
(default: false): Overwrite an existing file if it already existsOverview:
The DownloadFunc
class is an interface that exposes RESTful API functions for managing file downloads using the FileDownload
class, providing a simple way to start, stop, and manage multiple concurrent download tasks. It allows you to list all currently active downloads, delete specific ones or URLs, check their status, control their execution flow, as well as configure server-side parameters for managing downloads.
Features:
Configuration:
concurrency
(default: 3): Maximum number of concurrent downloads allowedrootDir
(required): Root directory where downloaded files will be storedautostartQueue
(default: true): Automatically start the next pending task in the queue after a file is completedcleanTempFile
(default: true): Whether to remove temporary files upon successful completionautoScaleDownloads
(default: false): If concurrency limit is reached, automatically stop an older download or report an errorMethods:
FAQs
The Large File Downloader for `ServerTools`
The npm package @isdk/ai-tool-downloader receives a total of 7 weekly downloads. As such, @isdk/ai-tool-downloader popularity was classified as not popular.
We found that @isdk/ai-tool-downloader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.