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 🙏

© 2024 – Pkg Stats / Ryan Hefner

multipart-uploader-backend

v4.0.1

Published

An easy-to-use npm module to reassemble multipart file uploads.

Downloads

17

Readme

MulitpartIO

An easy-to-use npm module to reassemble multipart file uploads.

Features

  • Clean, 1-line, promise-based API for each task, ensuring simplicity in usage.
  • Implemented First-Come-First-Serve (FCFS) scheduling to mitigate maximum file descriptor limitations.
  • Achieved peak disk-write speeds of up to 290 MB/s on a Windows machine with 16 GB RAM and Intel i5 12th processor with multiple processes running in background.
  • Cross platform module.

Installation

Install MultipartIO with npm

  npm install multipart-uploader-backend
  cd multipart-uploader-backend

Usage/Examples

const multipartUploader = require('multipart-uploader-backend');


// Configure the directory where you want the chunks and final merged files to be stores.
// This is optional.
multipartUploader.configure({
    chunksDirectory: process.env.CHUNKS_DIR,
    contentsDirectory: process.env.CONTENT_DIR
});


// Initialise the upload.
async function init(req, res){
    try {
        const { fileName, totalChunks  } = req.body;
        const { uploadId } = await multipartUploader.initialiseUpload(fileName.split(' ').join('_'), totalChunks);
        res.json({ uploadId });
    } catch (error) {
        res.status(500).json({ message: 'Some error' });
    }
};

// Send each chunk one by one.
async function upload(req, res){
    try {
        const result = await multipartUploader.chunkUpload(req);
        res.json(result);
    } catch (err){
        res.status(500).json({ message: 'Some error' });
    }
}

// Once all the chunks have been uploaded successfully, notify the server to start merging them.
async function complete(req, res){
    try {
        const { uploadId } = req.body;
        const result = await multipartUploader.completeUpload(uploadId);
        res.json(result);
    } catch (err) {
        res.status(500).json({ message: 'Some error' });
    }
}

API Reference

Initialise the upload

  multipartUploader.initialiseUpload( fileName, totalChunks )

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | fileName | string | Required. The name of the file to be uploaded. | | totalChunks | integer | Required. No. of chunks file is split into. |

Upload the chunk

  multipartUploader.chunkUpload( req )

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | req | Request | Required. NodeJS HTTP Request object. |

Upload the chunk

  multipartUploader.completeUpload( uploadId )

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | uploadId | string | Required. UploadId of the file to be merged. |

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For support, email [email protected] . If you encounter any problems or have any questions, please open an issue on the GitHub repository.