# file-chunk-upload

> file chunk upload

Latest version **0.3.24** (published 2019-05-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install file-chunk-upload
pnpm add file-chunk-upload
yarn add file-chunk-upload
bun add file-chunk-upload
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.24 |
| Published | 2019-05-27 |
| First published | 2018-11-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 135.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | dingyiwei |
| Maintainers | dingyw |
| Keywords | chunk, upload |

## Links

- npm: https://www.npmjs.com/package/file-chunk-upload
- Repository: https://github.com/zjsxdyw/file-chunk-upload
- Homepage: https://github.com/zjsxdyw/file-chunk-upload#readme
- Issues: https://github.com/zjsxdyw/file-chunk-upload/issues
- npm.io page: https://npm.io/package/file-chunk-upload

## Recent versions

- 0.3.24 (latest) — 2019-05-27
- 0.3.23 — 2018-12-20
- 0.3.22 — 2018-12-20
- 0.3.21 — 2018-12-20
- 0.3.19 — 2018-11-29
- 0.3.18 — 2018-11-29
- 0.3.16 — 2018-11-28
- 0.3.15 — 2018-11-28
- 0.3.14 — 2018-11-28
- 0.3.13 — 2018-11-28
- 0.3.12 — 2018-11-27
- 0.3.11 — 2018-11-27
- 0.3.10 — 2018-11-27
- 0.3.9 — 2018-11-27

## README

# file-chunk-upload

## Installation
```sh
npm install file-chunk-upload
```
### Import
- ESM
```js
import FileUploader from 'file-chunk-upload'
```
- CommonJS
```js
var FileUploader = require('file-chunk-upload')
```
- CDN

```html
<script src="https://unpkg.com/file-chunk-upload/dist/file-chunk-upload.min.js"></script>
```
### Usage
```js
var fileUploader = new FileUpload({
  // The first size of a file(in B) to breakpoint resume
  firstSize: 256 * 1024,
  // The size of a chunk(in B)
  chunkSize: 4 * 1024 * 1024,
  // The time of expiration
  expiration: 24 * 60 * 60,
  // Number of concurrent uploads
  maxConcurrent: 2,
  // Auto file upload
  autoUpload: true,
  // The url of prepare to upload
  prepareUrl: '/file/prepare',
  // The url of uploading every chunk
  uploadUrl: '/file/upload',
  // The url of checking md5
  checkUrl: '/file/check',
  // The url of merging file
  mergeUrl: '/file/merge',
  // The request headers
  headers: {},
  // The number of reupload the chunk if fail
  reupload: 5,
  // Upload success callback
  success: function(fileObj, response) {
    console.log(response);
  },
  // Upload error callback
  error: function(fileObj, error, type) {
    console.log(error, type);
  },
  // Upload progress callback
  progress: function(fileObj) {
    console.log(fileObj.percentage);
  }
});
// add File to fileUploader
var fileObj = fileUploader.addFile(file);
// if autoUpload is false
fileUploader.upload(fileObj);
// pause upload
fileUploader.pause(fileObj);
// continue upload
fileUploader.continue(fileObj);
// remove file
fileUploader.remove(fileObj);
```
## Example
```sh
npm install
npm run dev
```

---
_Source: https://npm.io/package/file-chunk-upload · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
