基于Vue的文件切片上传组件,兼容初始化查询、chunkHash校验,支持并发/串行上传、断点续传
npm install file-upload-slice-vuebash
npm install file-upload-slice-vue spark-md5 --save
`配置项
| 配置名 | 类型 | 默认值 | 说明 |
|--------------|----------|-----------------|--------------------------|
| initUrl | string | '' | 初始化查询接口地址 |
| uploadUrl | string | 必传 | 分片上传接口地址 |
| mergeUrl | string | 必传 | 文件合并接口地址 |
| chunkSize | number | 510241024 | 分片大小(默认5MB) |
| concurrency | number | 3 | 并发数(仅并发上传有效) |
| strategy | string | 'concurrent' | 上传策略(concurrent/serial) |使用示例
$3
`vue
已上传分片:{{ uploadedChunks.length }}/{{ chunkTotal }}
上传进度:{{ uploadProgress }}%
上传失败:{{ uploadError }}
`$3
`vue
:init-url="'http://localhost:3001/api/upload/init'"
:upload-url="'http://localhost:3001/api/upload/chunk'"
:merge-url="'http://localhost:3001/api/upload/merge'"
:chunk-size="2 1024 1024"
:concurrency="3"
strategy="concurrent"
@success="handleSuccess"
@failed="handleFailed"
/>
``