ChrisFuck faece1633d add babel | 5 years ago | |
---|---|---|
node_modules | 5 years ago | |
utils | 5 years ago | |
.babelrc | 5 years ago | |
.gitignore | 5 years ago | |
README.md | 5 years ago | |
contants.js | 5 years ago | |
index.js | 5 years ago | |
package-lock.json | 5 years ago | |
package.json | 5 years ago | |
utils.js | 5 years ago |
上传插件,不包含上传的前端实现,只提供后端接口等,其他地方接入插件上传。包括上传进度、断点续传等
"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