oa-uploader
v0.0.14
Published
OaUploader is base on `HTML5 FILE` API
Downloads
5
Readme
Base
OaUploader is base on HTML5 FILE
API
Install
npm install oa-uploader
then
import OaUploader from 'oa-uploader'
or
<script src="//unpkg.com/oa-uploader"></script>
Options
| option | detail | type | default |
| --------------------------------- | ---------------------- | ------------ | ------------------ |
| files | upload file array | Array | --- |
| chunkSize | chunk size | Number | (1 << 20) * 5
|
| parallel | upload parallel number | Number | 3 |
| fileParallel | file parallel number | Number | 2 |
| md5 | enable md5 calculate | Boolean | false
|
| maxMd5Size | max md5 calculate size | Number | (1 << 20) * 5000
|
| autoUpload | auto upload | Boolean | true
|
| onBeforeUpload(file) | before upload hook | Function | null
|
| onBeforeSend(file, formdata) | before request hook | Function | null
|
| onProgress(file, progress, speed) | progress hook | Function | null
|
| onOverAllProgress(progress) | uploaded hook | Function | null
|
| onAbort(file) | abort hook | Function | null
|
| onError(file) | error hook | Function | null
|
| onLoad(file, res) | success upload hook | Function | null
|
| el | file input element | String/DOM
| null
|
| onDrag | drag drop hook | Function | null
|
INSTANCE FUNCTION
| name | detail | argument |
| -------- | ---------- | -------- |
| retry | 重试 | index
|
| pause | 暂停 | index
|
| delete | 删除 | index
|
| stopAll | 全部停止 | null
|
| retryAll | 全部重试 | null
|
| addFiles | 增加新文件 | [file]
|
Usage
<input type="file" id="files" multiple>
window.onload = function () {
document.querySelector('#files')
.addEventListener('change', function(e) {
new OaUploader({
files: e.target.files,
md5: true,
uploadUrl: '/upload',
parallel: 3
});
});
}
ISSUE
- 文件上传过程中重命名处理