file-chunk-processor

0.0.1 • Public • Published

File chunk processing

Reads through a file and every 'x' bytes of the file, runs a processing function to do something with the chunk that has been read.

Could be used for uploading a file in chunks for example.

The callback function is specified in the form

function (dataReadBuffer, chunkIndex, bytesRead, totalFileSize) {...}

Installation

npm install --save file-chunk-processor

Usage

const fp = require('file-chunk-processor');

const config = {
  filePath: 'bigvideo.mp4',
  chunkSize: 1024 * 1024 * 2, // 2 mb
  processingFunc: (dataReadBuffer, chunkIndex, bytesRead, totalFileSize) => {
    // do something with data in buffer
    }
};


fp.processFile(config)
  .then(() => {
    // Do something when file has been processed.
  })
  .catch(err => {...});

Testing

npm test

Readme

Keywords

Package Sidebar

Install

npm i file-chunk-processor

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • graymanto