上传插件,不包含上传的前端实现,只提供后端接口等,其他地方接入插件上传。包括上传进度、断点续传等
"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)
})