ChrisFuck f7a8618cf7 add error code | 5 jaren geleden | |
---|---|---|
node_modules | 5 jaren geleden | |
utils | 5 jaren geleden | |
README.md | 5 jaren geleden | |
index.js | 5 jaren geleden | |
package-lock.json | 5 jaren geleden | |
package.json | 5 jaren geleden |
上传插件,不包含上传的前端实现,只提供后端接口等,其他地方接入插件上传。包括上传进度、断点续传等
"upload_sdk": "git+ssh://git@git.links123.net:npm/upload_sdk.git"
import UploadSdk from 'upload_sdk'
let uploadSdk = new UploadSdk(host,origin,token,file)
//上传图片,默认实现断点续传,如果上次上传中断,第二次上传如果服务器那边还没过期会接着上传
uploadSdk.imageUploadAction().then((res) => {
const { url } = res
this.updateFileList(file, url)
}).catch((err) => {
console.log(err)
})
//上传视频
uploadSdk.videoUploadAction().then((res) => {
const { url } = res
this.updateFileList(file, url)
}).catch((err) => {
console.log(err)
})
//监听上传进度,用于有显示上传进度条的需求
uploadSdk.onUpdateProgress( progress => {
console.log(progress)
})
IMAGE_TYPE_ERROR: 101,
VIDOE_TYPE_ERROR: 102,
UPLOAD_SUCCESS_CODE: 200,
UPLOAD_FAILED_CODE: 400