npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

innoboxrr-multipart-uploader

v3.0.2

Published

Módulo para subir archivos en partes, permitiendo reanudar las subidas de forma eficiente.

Downloads

18

Readme

📤 MultipartUploader

MultipartUploader es una clase JavaScript que permite subir archivos de gran tamaño en múltiples partes (multipart upload) utilizando rutas firmadas, ideal para integraciones con servicios como Amazon S3.

Compatible con AMD, CommonJS y uso directo en el navegador.


🚀 Instalación

Puedes incluirla directamente en tu proyecto como script:

<script src="MultipartUploader.js"></script>

O si usas módulos:

const MultipartUploader = require('./MultipartUploader');

🧱 Parámetros requeridos

Al instanciar MultipartUploader, debes pasar un fileIdentifier único y un objeto de configuración con los siguientes parámetros:

Props

| Parámetro | Tipo | Requerido | Descripción | | --------------------- | ---------- | --------- | -------------------------------------------------------------------------- | | fileIdentifier | string | ✅ | Identificador único del archivo a subir. | | token | string | ✅ | CSRF token para proteger las peticiones POST. | | initiateUploadRoute | string | ✅ | URL para iniciar la carga y obtener el upload_id. | | signPartUploadRoute | string | ✅ | URL para obtener las URLs firmadas de cada parte. | | completeUploadRoute | string | ✅ | URL para completar la carga y notificar al backend. | | filename | string | ❌ | Nombre original del archivo. | | allowedFileTypes | string[] | ❌ | Lista de MIME types permitidos. Usa ['*'] para permitir todos (default). | | chunkSize | number | ❌ | Tamaño de cada chunk en MB (default: 5 MB). | | maxRetries | number | ❌ | Máximo número de reintentos por parte (default: 3). |


📦 Ejemplo de uso

const uploader = new MultipartUploader('archivo-123', {
    token: document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
    initiateUploadRoute: '/api/upload/initiate',
    signPartUploadRoute: '/api/upload/sign-part',
    completeUploadRoute: '/api/upload/complete',
    allowedFileTypes: ['image/png', 'application/pdf'],
    chunkSize: 10, // en MB
    maxRetries: 5,
    filename: 'ejemplo.pdf'
});

// Registrar eventos
uploader
    .on('progress', (progress) => {
        console.log(`Progreso: ${progress.toFixed(2)}%`);
    })
    .on('complete', (res) => {
        console.log('Carga completa:', res);
    })
    .on('error', (err) => {
        console.error('Error durante la carga:', err);
    });

// Iniciar carga
document.getElementById('inputArchivo').addEventListener('change', function () {
    const file = this.files[0];
    uploader.startUpload(file);
});

⏸️ Pausar y Reanudar

Puedes pausar y reanudar la carga en cualquier momento:

uploader.pauseUpload();   // Pausa la carga
uploader.resumeUpload();  // Reanuda desde la última parte

📡 Eventos disponibles

| Evento | Descripción | Argumento | | ---------- | --------------------------------------------- | -------------------------------- | | progress | Se dispara con cada parte cargada | Porcentaje de progreso (number) | | complete | Se dispara al completar toda la carga | Objeto con status y response | | error | Se dispara cuando falla la carga de una parte | Mensaje de error (string) |


🛡️ Consideraciones de seguridad

  • Asegúrate de validar el file_identifier y filename en el backend.
  • Las rutas deben estar protegidas y validar el token CSRF.
  • El sistema debe manejar la recolección de partes (ETags) para completar el multipart upload correctamente.

📁 Backend esperado

Tu backend debe exponer 3 rutas:

  1. initiateUploadRoute: Retorna { upload_id: '...' }
  2. signPartUploadRoute: Retorna { url: 'https://...' } para cada parte.
  3. completeUploadRoute: Recibe { parts: [{ PartNumber, ETag }...] } y cierra la carga.

¿Quieres que también te genere la estructura de los endpoints en Laravel o Node.js?