cs_file_downloads_frontend
v1.0.2
Published
### Description: Module for downloading multiple files in chunks. Use it if you need to pause your downloads. See backend implementation https://www.npmjs.com/package/cs_file_downloads_backend
Downloads
3
Maintainers
Readme
CSFileDownloadFrontend
Description:
Module for downloading multiple files in chunks. Use it if you need to pause your downloads. See backend implementation https://www.npmjs.com/package/cs_file_downloads_backend
How to use:
Install:
npm i cs_file_downloads_frontend
Import CSDownload to your app:
import {CSDownload} from './node_modules/cs_file_downloads_frontend/CSDownload'
Configure CSDownload:
CSDownload.config({
'chunkSize': 1 * 1024 * 1024,
'concurrentRequests': 3,
'url': 'http://localhost:3000/',
'repeat': true,
'repeatCount': 5,
});
Download File:
// download function checks if a file exists on server
// returns singleFile object, a file currently downloading
let singleFile = CSDownload.download(file);
singleFile functions:
singleFile.pause() // pauses upload of a file
singleFile.continue() // continues upload of a file
Progress listener:
singleFile.eventEmitter.on('progress', (progress)=>{
// do something
})
Error listener:
singleFile.eventEmitter.on('error', (message)=>{
// do something
})
Use webpack to bundle your files:
webpack main.js