uploadx-client

0

Описание

A JavaScript client for resumable file uploads with chunking support.

Языки

  • TypeScript92,4%
  • JavaScript7,6%
README.md

UploadX Client

npm version

A JavaScript client for resumable file uploads with chunking support. Works with node-uploadx server implementation.

Features

  • Resumable Uploads: Continue uploads from where they left off after interruptions
  • Chunked Uploads: Split large files into manageable chunks
  • Progress Tracking: Real-time upload progress monitoring
  • Cross-Platform: Works in both browser and Node.js environments
  • Multiple Data Sources: Support for File, Blob, Stream, Buffer, and more
  • Automatic Retries: Built-in retry mechanism with exponential backoff
  • Cancellation: Ability to abort ongoing uploads

Installation

Usage

Basic File Upload (Node.js)

Browser Upload (with File object)

Manual Upload Session

You can manually create an upload session and then upload data to it. This is useful when you need more control over the upload process or when implementing custom upload workflows:

API Reference

UploadxClient

Constructor

Parameters:

  • config
    (optional): Configuration options
    • chunkSize
      : Size of each chunk in bytes (default: 5MB)
    • retryConfig
      : Configuration for axios-retry
    • requestConfig
      : Configuration for axios requests

Methods

fileUpload

Uploads a file from disk (Node.js only).

upload

Uploads data from various sources (Blob, File, Stream, Buffer).

resumeUpload

Resumes an upload from a previously created session.

resumeFileUpload

Resumes a file upload from disk (Node.js only).

createUpload

Creates a new upload session on the server.

updateUpload

Updates metadata for an existing upload.

getUploadStatus

Gets the current upload progress from the server.

deleteUpload

Deletes an existing upload from the server.

abort

Aborts all ongoing upload operations.

Types

UploadMetadata

ProgressCallback

Examples

The repository includes example code to help you get started:

Upload Client Example

examples/client.ts demonstrates how to upload a file with progress tracking:

Browser Example

The repository includes a browser demo (examples/browser/index.html) that shows how to implement resumable uploads in web applications with progress tracking, session management, and upload controls (upload, abort, resume, delete).

Server Requirements

This client is specifically designed to work with the node-uploadx server implementation, which provides the necessary protocol support for resumable uploads.

License

MIT