# cs-file-transfer-upload

> #### Description: Module allows uploading multiple files in chunks. Use it if you need to pause your uploads. For backend you can use values from req.body like this: ```Javascript let { slice, fileName, chunkNumber, numberOfChunks, size } = req.body; ```

Latest version **2.0.5** (published 2019-05-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install cs-file-transfer-upload
pnpm add cs-file-transfer-upload
yarn add cs-file-transfer-upload
bun add cs-file-transfer-upload
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.5 |
| Published | 2019-05-07 |
| First published | 2019-05-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | mislav.clover |
| Keywords | npm, upload, chunked, pause, frontend |

## Links

- npm: https://www.npmjs.com/package/cs-file-transfer-upload
- Repository: https://github.com/cloverstudio/CSFileTransferFrontend
- Homepage: https://github.com/cloverstudio/CSFileTransferFrontend#readme
- Issues: https://github.com/cloverstudio/CSFileTransferFrontend/issues
- npm.io page: https://npm.io/package/cs-file-transfer-upload

## Dependencies (7)

- [webpack](https://npm.io/package/webpack.md) ^4.30.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.4.3
- [webpack-cli](https://npm.io/package/webpack-cli.md) ^3.3.1
- [babel-loader](https://npm.io/package/babel-loader.md) ^8.0.5
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.26.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.4.3
- [webpack-dev-server](https://npm.io/package/webpack-dev-server.md) ^3.3.1

## Recent versions

- 2.0.5 (latest) — 2019-05-07
- 2.0.4 — 2019-05-06
- 2.0.3 — 2019-05-06
- 2.0.2 — 2019-05-06
- 2.0.1 — 2019-05-06
- 3.0.0 — 2019-05-06
- 2.0.0 — 2019-05-06
- 1.0.0 — 2019-05-06

## README

# cs-file-transfer-upload frontend

#### Description:
Module allows uploading multiple files in chunks. Use it if you need to pause your uploads.
For backend you can use values from req.body like this:
```Javascript
let { slice, fileName, chunkNumber, numberOfChunks, size } = req.body;
```
Slice is base 64 encoded. You can also use npm module https://www.npmjs.com/package/cs-file-transfer-upload-backend

#### How to use:

#### Install:

`npm i cs-file-transfer-upload`

#### Import CSUpload to your main file:
```Javascript
import {CSUpload} from './node_modules/cs-file-transfer-upload/CSUpload'
```

#### Configure CSUpload:
```Javascript
CSUpload.config({
	'chunkSize': 5 * 1024 * 1024,	// size of a chunk in bytes, default is 1 * 1024 * 1024
	'concurrentRequests': 3,       // number of chunks sent at the same time (max value depends on browser), default is 1
	'url': 'http://localhost:3000/',	// server
	'repeat': true,	// if error happens retry, default is true
    	'repeatCount': 5	// if error happens retry 5 more times
})
```
#### Upload file:
```Javascript
singleFile = CSUpload.upload(file)	
// upload function returns singleFile object, a file currently uploading
// you can also add another argument, url that overrides the previously set url
```

#### singleFile functions:
```Javascript
singleFile.pause()	// pauses upload of a file
singleFile.continue()	// continues upload of a file
```

#### Progress listener:
```Javascript
singleFile.eventEmitter.on('progress', (progress)=>{
	// do something
})
```

#### Error listener:
```Javascript
singleFile.eventEmitter.on('error', (message)=>{
	// do something
})
```

#### Use webpack to bundle your files:
`webpack main.js`

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