1.0.0 • Published 7 months ago
file-burst v1.0.0
Install
Get the latest version from NPM:
npm install file-burst
Also available with yarn:
yarn add file-burst
Usage
Usage as library
import FileBurst from 'file-burst';
const Burst = new FileBurst(file, {
burstSize: 10 * 1024, // 每片大小 (10M)
uploadAbortCallBack: function (e) {
console.log(`被打断请求信息:`, e);
}, // 请求函数被打断回调
data: {}, // 网络请求参数
name: "file", // 上传的文件字段名, 会放到请求体
uploadUrl: "", // 网络请求地址
progressCallBack: function (percentage, index) {
console.log(`当前进度:${percentage}; 当前上传第${index + 1}个文件`);
}, // 请求进度回调
headerConfig: {}, // 设置请求头
});
const upload = Burst.upload(); // 发送请求
upload.abort(); // 请求终止
upload.then((res) => { // 最终请求完成返回
console.log(res); // response body
}).catch((e) => {
console.log(e);
});
options available
Contributing
only me
License
1.0.0
7 months ago