阿里云OSS 服务端签名后直传之分片上传(结合element-ui的upload组件)
生活随笔
收集整理的这篇文章主要介绍了
阿里云OSS 服务端签名后直传之分片上传(结合element-ui的upload组件)
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
分片上传(结合element-ui的upload组件实现自定义上传)
async uploadFree(content){let data = await this.getOssToken(); //后台返回的OSS秘钥等等let client = new OSS({region: data.region,accessKeyId: data.AccessKeyId,accessKeySecret: data.AccessKeySecret,stsToken: data.SecurityToken,bucket: data.bucketName});try {let result = await client.multipartUpload(content.file.name, content.file, {progress: async function (p) {//这是上传进度条content.onProgress({percent: parseInt(p * 100)+'%', returnValue: true });}});return (content.file['response'] = [result].map(curr =>{//on-change回调的参数return {code: curr.res.status,name: content.file.name,data: curr.res.requestUrls[0].split('?')[0]}})[0]);} catch (e) {console.log(e)if (e.code === 'ConnectionTimeoutError') {content.onError('视频上传超时')throw "视频上传超时!";}else{content.onError('视频上传失败')}} }
官方文档: 传送门
转载于:https://www.cnblogs.com/guojikun/p/9685143.html
总结
以上是生活随笔为你收集整理的阿里云OSS 服务端签名后直传之分片上传(结合element-ui的upload组件)的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: (WPF, MVVM) Event 处理
- 下一篇: ReactNative之从HelloWo